From 72df3338d3ddb8136801a8cd7f165c5f94f937ab Mon Sep 17 00:00:00 2001 From: Gregor Michels Date: Tue, 7 Mar 2023 23:44:19 +0100 Subject: [PATCH] monitoring: nice labels for openwrt switches * keep instance label * add site and location labels --- templates/prometheus.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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: