From 76fa4ddc78a3c202cc98230f5c5dfaafe3b20820 Mon Sep 17 00:00:00 2001 From: Remy Mollandin Date: Mon, 4 Sep 2023 20:25:28 +0200 Subject: [PATCH] [prometheus-mysql-exporter]: add default relabeling for multiple target Signed-off-by: Remy Mollandin --- .../templates/servicemonitor.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/charts/prometheus-mysql-exporter/templates/servicemonitor.yaml b/charts/prometheus-mysql-exporter/templates/servicemonitor.yaml index 5da3eccb7b51..be5bbb5d3dc5 100644 --- a/charts/prometheus-mysql-exporter/templates/servicemonitor.yaml +++ b/charts/prometheus-mysql-exporter/templates/servicemonitor.yaml @@ -40,9 +40,18 @@ spec: {{- if $.Values.serviceMonitor.scrapeTimeout }} scrapeTimeout: {{ $.Values.serviceMonitor.scrapeTimeout }} {{- end }} - {{- if $.Values.serviceMonitor.metricRelabelings }} - metricRelabelings: {{ toYaml $.Values.serviceMonitor.metricRelabelings | nindent 8 }} - {{- end }} + metricRelabelings: + - action: replace + replacement: {{ .endpoint }} + sourceLabels: [instance] + targetLabel: instance + - action: replace + replacement: {{ .name }} + sourceLabels: [target] + targetLabel: target + {{- if $.Values.serviceMonitor.metricRelabelings -}} + {{ toYaml $.Values.serviceMonitor.metricRelabelings | nindent 8 }} + {{- end }} {{- if $.Values.serviceMonitor.relabelings }} relabelings: {{ toYaml $.Values.serviceMonitor.relabelings | nindent 8 }} {{- end }}