Skip to content

Commit

Permalink
[prometheus-snmp-exporter] Extend metric relabels (#4490)
Browse files Browse the repository at this point in the history
* [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 <distant.calls@gmail.com>

* Update charts/prometheus-snmp-exporter/values.yaml

Apply suggested changes

Co-authored-by: Tom Walker <walker.thomas.p@gmail.com>
Signed-off-by: ngc4579 <distant.calls@gmail.com>

* Update charts/prometheus-snmp-exporter/values.yaml

Apply suggested changes

Co-authored-by: Tom Walker <walker.thomas.p@gmail.com>
Signed-off-by: ngc4579 <distant.calls@gmail.com>

---------

Signed-off-by: ngc4579 <distant.calls@gmail.com>
Co-authored-by: Tom Walker <walker.thomas.p@gmail.com>
  • Loading branch information
ngc4579 and walker-tom committed Apr 28, 2024
1 parent 9c41858 commit f93d563
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/prometheus-snmp-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 3 additions & 0 deletions charts/prometheus-snmp-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
17 changes: 17 additions & 0 deletions charts/prometheus-snmp-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ 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: {}
# targetLabel1: replacementValue1
# targetLabel2: replacementValue2

# 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
Expand Down Expand Up @@ -214,7 +228,10 @@ 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: []

# Extra manifests to deploy as an array
extraManifests: []
Expand Down

0 comments on commit f93d563

Please sign in to comment.