Environment variables in prometheus.yml file

4,679 views
Skip to first unread message

daniel.la...@gmail.com

unread,
Dec 7, 2015, 1:48:47 PM12/7/15
to Prometheus Developers
Hi!

Is there any way to get an environment variable and use it in the prometheus.yml file?

For example, i have the env variable IP_ADDRESS and i want to use it like an endpoint in my job target like this:

- job_name: 'foo'
target_groups:
- targets: ['IP_ADDRESS:8080']

Thanks in advance!

Brian Brazil

unread,
Dec 7, 2015, 2:12:31 PM12/7/15
to daniel.la...@gmail.com, Prometheus Developers
On Mon, Dec 7, 2015 at 6:48 PM, <daniel.la...@gmail.com> wrote:
Hi!

Is there any way to get an environment variable and use it in the prometheus.yml file?

Not directly, but you could use a tool such as sed to alter the config file:

sed -i '' -e "s/IP_ADDRESS/$IP_ADDRESS/" prometheus.yml

Brian
 

For example, i have the env variable IP_ADDRESS and i want to use it like an endpoint in my job target like this:

- job_name: 'foo'
   target_groups:
     - targets: ['IP_ADDRESS:8080']

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Daniel Lara

unread,
Dec 9, 2015, 2:43:11 AM12/9/15
to Brian Brazil, Prometheus Developers
Thanks for the answer. It works!

Reply all
Reply to author
Forward
0 new messages