[prometheus-json-exporter] Support full relabeling spec in additionalMetricsRelabels#6994
Open
alien2003 wants to merge 2 commits into
Open
Conversation
…MetricsRelabels The serviceMonitor additionalMetricsRelabels value only accepted a map of targetLabel/replacement pairs, each rendered as a `replace` metric relabeling. This rules out regex, sourceLabels, drop/keep and the rest of the Prometheus relabeling spec. Accept a list of full relabeling objects in addition to the existing map, the same way additionalRelabels already works in this template. The map form is unchanged, so this is backward compatible. Add a servicemonitor unittest suite covering both forms, their precedence via defaults, and empty inputs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: alien2003 <alien2003@protonmail.ch>
zanhsieh
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it
The
serviceMonitoradditionalMetricsRelabelsvalue only accepts a map oftargetLabel: replacementpairs, each rendered as areplacemetricrelabeling. That excludes the rest of the Prometheus relabeling spec (
regex,sourceLabels,drop/keep,labelmap, and so on).This change lets
additionalMetricsRelabelsalso accept a list of fullrelabeling objects, rendered verbatim after the two built-in
instance/targetrelabelings. It mirrors how
additionalRelabelsalready handlesrelabelingsin the same template. The value type is detected with
kindIs "slice", whichis already used elsewhere in the repo (
kube-state-metrics,kube-prometheus-stack).Both per-target and
serviceMonitor.defaultsaccept either form, with theper-target value taking precedence as before. The map form renders identical
output to today, so this is backward compatible and bumped as a minor version.
A
servicemonitorunittest suite is added (the chart had none) covering the mapform, the list form,
defaultsprecedence, and empty map/list inputs.Which issue this PR fixes
Special notes for your reviewer
Verified with the pinned CI tooling:
Checklist
[prometheus-couchdb-exporter])