Skip to content

Commit

Permalink
Add an example that uses environment variables (#698)
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall authored Aug 23, 2024
1 parent 3a68a88 commit c2ed2f9
Show file tree
Hide file tree
Showing 7 changed files with 61,588 additions and 0 deletions.
53 changes: 53 additions & 0 deletions examples/environment-variables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Environment Variables

In this example, we show how to set environment variables in the Alloy instance and a few examples of how to use them.

This can be extended to set environment variables in any of the Alloy instances.

```yaml
---
cluster:
name: environment-variables-test

externalServices:
prometheus:
host: https://prometheus.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"
externalLabelsFrom:
company: env("COMPANY") # label set from environment variable
team: env("team") # label set from environment variable found in the ConfigMap
loki:
host: https://loki.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"

metrics:
# Environment variable used in a relabeling rule
extraMetricRelabelingRules: |-
rule {
target_label = "region"
replacement = env("region")
}
alloy:
alloy:
extraEnv: # Set environment variables directly
- name: COMPANY
value: "Widget Co"
extraEnvFrom: # Set environment variables from a ConfigMap
- configMapRef:
name: team-params

# Deploy the ConfigMap with the environment variables. Typically, this would already exist in your cluster.
extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: common-params
data:
team: "Team A"
region: "midwest"
```
48 changes: 48 additions & 0 deletions examples/environment-variables/events.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 155 additions & 0 deletions examples/environment-variables/logs.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c2ed2f9

Please sign in to comment.