From 085678dc6640c7da4f11c36d80c8ff045512c0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Mon, 27 Jul 2020 18:40:18 +0200 Subject: [PATCH] Fix blackbox target's metrics labels (#22546) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The metrics labels currently generated does not match what is generated by the setup described here: https://prometheus.io/docs/guides/multi-target-exporter/#querying-multi-target-exporters-with-prometheus and https://github.com/prometheus/blackbox_exporter#prometheus-configuration The previous metricsRelabeling is only valid if the target contains the URLs to check. What we need in the end is: - `__address__` set to the blackbox exporter, and it it already the case as the `selector` matches the blackbox exporter, - `__param_target` set to the target to check, and it is already ensure without relabeling, - `instance` set to the target to check. This patches ensures that the metrics has this labels: ``` probe_success{endpoint="http",instance="http://prometheus.io",job="blackbox-exporter-prometheus-blackbox-exporter",namespace="monitoring",pod="blackbox-exporter-prometheus-blackbox-exporter-84d9b64646-vgqcc",service="blackbox-exporter-prometheus-blackbox-exporter"} 1 ``` Without this patch, we have this (note that we lost the `instance` label): ``` probe_success{endpoint="http",job="blackbox-exporter-prometheus-blackbox-exporter",namespace="monitoring",pod="blackbox-exporter-prometheus-blackbox-exporter-84d9b64646-vgqcc",service="blackbox-exporter-prometheus-blackbox-exporter",target="prometheus-io"} 1 ``` Signed-off-by: Mickaël Canévet --- stable/prometheus-blackbox-exporter/Chart.yaml | 2 +- .../templates/servicemonitor.yaml | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/stable/prometheus-blackbox-exporter/Chart.yaml b/stable/prometheus-blackbox-exporter/Chart.yaml index 663ff8eb96..3b5b016bd8 100644 --- a/stable/prometheus-blackbox-exporter/Chart.yaml +++ b/stable/prometheus-blackbox-exporter/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Prometheus Blackbox Exporter name: prometheus-blackbox-exporter -version: 4.1.1 +version: 4.2.0 appVersion: 0.16.0 home: https://github.com/prometheus/blackbox_exporter sources: diff --git a/stable/prometheus-blackbox-exporter/templates/servicemonitor.yaml b/stable/prometheus-blackbox-exporter/templates/servicemonitor.yaml index 1af8119baa..b7c461cc12 100644 --- a/stable/prometheus-blackbox-exporter/templates/servicemonitor.yaml +++ b/stable/prometheus-blackbox-exporter/templates/servicemonitor.yaml @@ -26,10 +26,8 @@ spec: target: - {{ .url }} metricRelabelings: - - sourceLabels: [__address__] - targetLabel: __param_target - - sourceLabels: [__param_target] - targetLabel: instance + - targetLabel: instance + replacement: {{ .url }} - targetLabel: target replacement: {{ .name }} jobLabel: "{{ $.Release.Name }}" @@ -42,4 +40,3 @@ spec: - {{ $.Release.Namespace }} {{- end }} {{- end }} -