prometheus.yml dynamic update

148 views
Skip to first unread message

govinda...@gmail.com

unread,
May 16, 2017, 2:56:39 PM5/16/17
to Prometheus Users
Is there a way i can pass run time variable when running prometheus docker and update prometheus.yml with this vaule?

docker run -d -p 9100:9100 --net="host" --name="prometheus" -e CONSUL='consul.com' prometheus:latest


prometheus.yml
```
    - server: ${CONSUL}:8500
      datacenter: 'MyDC'
      services: ['telegraf']
```

$CONSUL should be replaced with consul.com

Thoughts?


Brian Brazil

unread,
May 16, 2017, 2:57:55 PM5/16/17
to govinda...@gmail.com, Prometheus Users
This isn't supported by Prometheus itself, however you could use shell substitution to sed to the same effect. 

--

govinda...@gmail.com

unread,
May 16, 2017, 3:21:45 PM5/16/17
to Prometheus Users, govinda...@gmail.com
Thanks Brian. You guys do it inside the prometheus.yml file? 

Brian Brazil

unread,
May 16, 2017, 3:41:19 PM5/16/17
to govinda...@gmail.com, Prometheus Users
On 16 May 2017 at 20:21, <govinda...@gmail.com> wrote:
Thanks Brian. You guys do it inside the prometheus.yml file? 

prometheus.yml is intentionally dumb, any substitution needs to be done by something else.

Brian
 
--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/45c99df5-374c-4dd0-9f96-7e2f1e21483f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Wojciech Sciesinski

unread,
May 17, 2017, 5:36:22 PM5/17/17
to Prometheus Users, govinda...@gmail.com
You can do it using Ansible and builtin modules for it
- template: to prepare the prometheus.yml file (delegate_to: localhost)
- shell: to run promtool  to parse the prepared file )delegate_to: localhost) -
- copy: to copy parsed file to Docker host
- docker_container: to create and start Prometheus Server docker container

Documentation for Ansible you can find here: https://docs.ansible.com/ansible/

Reply all
Reply to author
Forward
0 new messages