From 22aee43650ec8f3f54eeff8b5e3d6c5cfe634b49 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras <evangelos@foutrelis.com> Date: Mon, 18 Apr 2022 05:56:21 +0300 Subject: [PATCH] prometheus: restrict vhost handling to http_prometheus Makes prometheus.yml less noisy and doesn't break when non-vhost mappings are added to blackbox_targets. --- roles/prometheus/templates/prometheus.yml.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index a6d3625ce..04b0ba54d 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -155,6 +155,7 @@ scrape_configs: {% for target in blackbox_targets[module] | select('string') %} - {{ target }} {% endfor %} +{% if module == 'http_prometheus' %} {% for vhost in blackbox_targets[module] | select('mapping') %} - targets: {% for target in vhost.targets %} @@ -163,6 +164,7 @@ scrape_configs: labels: vhost: {{ vhost.hostname }} {% endfor %} +{% endif %} relabel_configs: - source_labels: [__address__] target_label: __param_target @@ -170,8 +172,10 @@ scrape_configs: target_label: instance - target_label: __address__ replacement: 127.0.0.1:9115 +{% if module == 'http_prometheus' %} - source_labels: [vhost] target_label: __param_hostname +{% endif %} {% endfor %} {% for endpoint in matrix_metrics_endpoints %} -- GitLab