diff --git a/templates/prometheus.yml b/templates/prometheus.yml index be8dcb0..915eb67 100644 --- a/templates/prometheus.yml +++ b/templates/prometheus.yml @@ -38,9 +38,16 @@ scrape_configs: - job_name: 'snmp' static_configs: - - targets: {% for host in groups['switches_stock'] %} - - {{ hostvars[host]['ip'] }} + - targets: ["{{ hostvars[host]['ip'] }}"] + labels: + instance: "{{ host }}" +{% if hostvars[host]['site'] is defined %} + site: "{{ hostvars[host]['site'] }}" +{% endif %} +{% if hostvars[host]['location'] is defined %} + location: "{{ hostvars[host]['location'] }}" +{% endif %} {% endfor %} metrics_path: /snmp params: