From 165867600b527ec416d39702e4d9d51b575c7828 Mon Sep 17 00:00:00 2001 From: ngc4579 Date: Fri, 26 Apr 2024 11:44:25 +0200 Subject: [PATCH] [prometheus-snmp-exporter] Extend metric relabels - In addition to fixed '$key: $value' metric relabelings, allow arbitrary relabel configs in order to support e.g. common label prefixes Signed-off-by: ngc4579 --- charts/prometheus-snmp-exporter/Chart.yaml | 2 +- .../templates/servicemonitor.yaml | 3 +++ charts/prometheus-snmp-exporter/values.yaml | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/charts/prometheus-snmp-exporter/Chart.yaml b/charts/prometheus-snmp-exporter/Chart.yaml index 9258438492a9..6c351c5a878c 100644 --- a/charts/prometheus-snmp-exporter/Chart.yaml +++ b/charts/prometheus-snmp-exporter/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Prometheus SNMP Exporter name: prometheus-snmp-exporter -version: 5.2.0 +version: 5.3.0 appVersion: v0.25.0 home: https://github.com/prometheus/snmp_exporter sources: diff --git a/charts/prometheus-snmp-exporter/templates/servicemonitor.yaml b/charts/prometheus-snmp-exporter/templates/servicemonitor.yaml index 9ac3218e5fc4..7731368b1428 100644 --- a/charts/prometheus-snmp-exporter/templates/servicemonitor.yaml +++ b/charts/prometheus-snmp-exporter/templates/servicemonitor.yaml @@ -39,6 +39,9 @@ spec: replacement: {{ $replacement }} action: replace {{- end }} + {{- if (or .additionalMetricsRelabelConfigs $.Values.serviceMonitor.additionalMetricsRelabelConfigs) }} + {{- toYaml (default $.Values.serviceMonitor.additionalMetricsRelabelConfigs .additionalMetricsRelabelConfigs) | nindent 6 }} + {{- end }} {{- if (or .relabelings $.Values.serviceMonitor.relabelings) }} relabelings: {{- toYaml (default $.Values.serviceMonitor.relabelings .relabelings) | nindent 6 }} diff --git a/charts/prometheus-snmp-exporter/values.yaml b/charts/prometheus-snmp-exporter/values.yaml index f1b244432b52..2cf4e4a6d844 100644 --- a/charts/prometheus-snmp-exporter/values.yaml +++ b/charts/prometheus-snmp-exporter/values.yaml @@ -185,8 +185,20 @@ serviceMonitor: # Metric relabeling is applied to samples as the last step before ingestion. # Set if defined unless overriden by params.additionalMetricsRelabels. + # This sets fixed relabel configs with action 'replace'. additionalMetricsRelabels: {} + # Metric relabeling is applied to samples as the last step before ingestion. + # Set if defined unless overridden by params.additionalMetricsRelabelConfigs. + # This allows setting arbitrary relabel configs. + # https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#monitoring.coreos.com/v1.RelabelConfig + additionalMetricsRelabelConfigs: [] + # - sourceLabels: [__name__] + # targetLabel: __name__ + # action: replace + # regex: (.*) + # replacement: prefix_$1 + # Label for selecting service monitors as set in Prometheus CRD. # https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#monitoring.coreos.com/v1.PrometheusSpec selector: @@ -215,6 +227,8 @@ serviceMonitor: # relabelings: [] # Map of metric labels and values to add. Overrides value set in serviceMonitor.additionalMetricsRelabels # additionalMetricsRelabels: {} + # Metrics relabelings. Overrides value set in serviceMonitor.additionalMetricsRelabelConfigs + # additionalMetricsRelabelConfigs: [] # Extra manifests to deploy as an array extraManifests: []