From a4aaa50f35d6d58a0ccf3e089622a6bc4d023899 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 7 Feb 2023 00:26:47 +0100 Subject: prometheus targets: cleanup and add support for target specific labels --- .../prometheus/exporter/register/templates/blackbox/probe.yml.j2 | 3 +++ roles/monitoring/prometheus/exporter/register/templates/generic.yml.j2 | 3 +++ .../prometheus/exporter/register/templates/ipmi/remote.yml.j2 | 3 +++ roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 | 3 +++ .../prometheus/exporter/register/templates/snmp/probe.yml.j2 | 3 +++ .../monitoring/prometheus/exporter/register/templates/ssl/probe.yml.j2 | 3 +++ 6 files changed, 18 insertions(+) (limited to 'roles/monitoring/prometheus/exporter/register/templates') diff --git a/roles/monitoring/prometheus/exporter/register/templates/blackbox/probe.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/blackbox/probe.yml.j2 index 47e6dceb..3ecf129a 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/blackbox/probe.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/blackbox/probe.yml.j2 @@ -3,3 +3,6 @@ instance: '{{ target.instance }}' __param_target: '{{ target.config.target }}' __param_module: '{{ target.config.module }}' +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} diff --git a/roles/monitoring/prometheus/exporter/register/templates/generic.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/generic.yml.j2 index 341cb45a..f269cf3a 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/generic.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/generic.yml.j2 @@ -1,3 +1,6 @@ - targets: [ '{{ (target.instance == prometheus_server) | ternary('127.0.0.1:9999', hostvars[target.instance].prometheus_scrape_endpoint) }}' ] labels: instance: '{{ target.instance }}' +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} diff --git a/roles/monitoring/prometheus/exporter/register/templates/ipmi/remote.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/ipmi/remote.yml.j2 index 47e6dceb..3ecf129a 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/ipmi/remote.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/ipmi/remote.yml.j2 @@ -3,3 +3,6 @@ instance: '{{ target.instance }}' __param_target: '{{ target.config.target }}' __param_module: '{{ target.config.module }}' +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} diff --git a/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 index a25cdfe5..5181f4e4 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 @@ -15,3 +15,6 @@ {% if 'statuses' in target.config %} __param_statuses: '{{ target.config.statuses }}' {% endif %} +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} diff --git a/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2 index 47e6dceb..3ecf129a 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2 @@ -3,3 +3,6 @@ instance: '{{ target.instance }}' __param_target: '{{ target.config.target }}' __param_module: '{{ target.config.module }}' +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} diff --git a/roles/monitoring/prometheus/exporter/register/templates/ssl/probe.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/ssl/probe.yml.j2 index 47e6dceb..3ecf129a 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/ssl/probe.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/ssl/probe.yml.j2 @@ -3,3 +3,6 @@ instance: '{{ target.instance }}' __param_target: '{{ target.config.target }}' __param_module: '{{ target.config.module }}' +{% for name, value in prometheus_target_labels.items() %} + {{ name }}: '{{ value }}' +{% endfor %} -- cgit v1.2.3