Created
December 15, 2016 16:19
-
-
Save wtip/e3a0851b27a96f311045a3dbffc46716 to your computer and use it in GitHub Desktop.
Ansible template that uses ansible inventory data to generate file based service discovery for prometheus to scrape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Uses ansible inventory to generate file based service discovery for prometheus to scrap | |
{# Loop over all groups except some #} | |
{% for group in groups if not group in ['all', 'ungrouped', prometheus_node_exporter_group] %} | |
{# Loop through hosts in group, if host is part of the prom-exports group, print hostname and port #} | |
- targets: [{% for host in groups[group] %}{% if prometheus_node_exporter_group in hostvars[host].group_names %}'{{ host }}:{{ prometheus_node_exporter_port }}', {% endif %}{% endfor %}] | |
labels: | |
job: '{{ group }}' | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment