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 }}