From 165867600b527ec416d39702e4d9d51b575c7828 Mon Sep 17 00:00:00 2001 From: ngc4579 Date: Fri, 26 Apr 2024 11:44:25 +0200 Subject: [PATCH 1/3] [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: [] From 6780c31c0efa5f7a07d024801f058385e6860d79 Mon Sep 17 00:00:00 2001 From: ngc4579 Date: Sat, 27 Apr 2024 20:42:30 +0200 Subject: [PATCH 2/3] Update charts/prometheus-snmp-exporter/values.yaml Apply suggested changes Co-authored-by: Tom Walker Signed-off-by: ngc4579 --- charts/prometheus-snmp-exporter/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/prometheus-snmp-exporter/values.yaml b/charts/prometheus-snmp-exporter/values.yaml index 2cf4e4a6d844..287b3a10df09 100644 --- a/charts/prometheus-snmp-exporter/values.yaml +++ b/charts/prometheus-snmp-exporter/values.yaml @@ -226,6 +226,7 @@ serviceMonitor: # Relabelings. Overrides value set in serviceMonitor.relabelings # relabelings: [] # Map of metric labels and values to add. Overrides value set in serviceMonitor.additionalMetricsRelabels + # This sets fixed relabel configs with action 'replace'. # additionalMetricsRelabels: {} # Metrics relabelings. Overrides value set in serviceMonitor.additionalMetricsRelabelConfigs # additionalMetricsRelabelConfigs: [] From 5fed892416df796a9b0c420e05c0961a6ac20151 Mon Sep 17 00:00:00 2001 From: ngc4579 Date: Sat, 27 Apr 2024 20:43:08 +0200 Subject: [PATCH 3/3] Update charts/prometheus-snmp-exporter/values.yaml Apply suggested changes Co-authored-by: Tom Walker Signed-off-by: ngc4579 --- charts/prometheus-snmp-exporter/values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/prometheus-snmp-exporter/values.yaml b/charts/prometheus-snmp-exporter/values.yaml index 287b3a10df09..a15074b44cb6 100644 --- a/charts/prometheus-snmp-exporter/values.yaml +++ b/charts/prometheus-snmp-exporter/values.yaml @@ -187,6 +187,8 @@ serviceMonitor: # Set if defined unless overriden by params.additionalMetricsRelabels. # This sets fixed relabel configs with action 'replace'. additionalMetricsRelabels: {} + # targetLabel1: replacementValue1 + # targetLabel2: replacementValue2 # Metric relabeling is applied to samples as the last step before ingestion. # Set if defined unless overridden by params.additionalMetricsRelabelConfigs.