Reputation: 7764
i would like to set environment specific values based on environment qa/prod in prometheus values file
## Additional alertmanager container environment variable
## For instance to add a http_proxy
##
extraEnv: {}
Upvotes: 9
Views: 24068
Reputation: 3417
Prometheus does not support environment variables. There are a few threads discussing this in GitHub.
You can use envsubs or if you want a more robust and versatile tool I recommend to GO with Confd (its written in GO :D). You can also get the secrets from backends like etcd or AWS ssm.
Here you have Prometheus with confd ready to go (just need to modify the config to your needs).
Upvotes: 8
Reputation: 321
Prometheus supports environment variables on some fields since v3.0
.
See the http_config
field reference for documentation on setting proxies using environment variables.
You can also look at the external_label
field in the same page to see how to set labels based on environment variables.
Upvotes: 1
Reputation: 17784
Prometheus doesn't support environment variables in config file. But other Prometheus-like systems such as VictoriaMetrics support env vars in Prometheus-compatible config files via %{ENV_VAR}
syntax. For example, the following config would substitute %{ENV}
with qa
or prod
if the corresponding ENV=qa
or ENV=prod
environment variable is passed to VictoriaMetrics or vmagent:
scrape_configs:
- job_name: foo
static_configs:
- targets: [foobar:1234]
labels:
env: '%{ENV}'
This allows using the same Prometheus config in different environments and templating it with environment variables. See these docs for details.
Upvotes: 0