Skip to content

[prometheus-json-exporter] additionalMetricsRelabels: support full relabeling spec (regex, sourceLabels, actions) #6924

Open

Description

@krishanthisera

Is your feature request related to a problem ?

Yes

The additionalMetricsRelabels field in the prometheus-json-exporter ServiceMonitor template currently only supports simple key-value string replacements. This limits its capability compared to the full Prometheus relabeling specification.

See: here

Current Implementation
The current template hardcodes simple replacements:

{{- range $targetLabel, $replacement := .additionalMetricsRelabels | default $.Values.serviceMonitor.defaults.additionalMetricsRelabels }}
- targetLabel: {{ $targetLabel }}
  replacement: {{ $replacement }}
  action: replace
{{- end }}

This only allows simple label replacement:

additionalMetricsRelabels:
  label1: "value1"
  label2: "value2"

Expected Behaviour

The template should support the full Prometheus relabeling spec, allowing users to define:

additionalMetricsRelabels:
  - sourceLabels: [some_label]
    regex: '(.+)\.(.+)'
    replacement: '${1}-${2}'
    targetLabel: custom_label
    action: replace

Describe the solution you'd like.

Update the template to iterate over a list of relabeling configurations instead of a map:

...
    metricRelabelings:
     ...
      {{- with .additionalMetricsRelabels | default $.Values.serviceMonitor.defaults.additionalMetricsRelabels }}
      {{- toYaml . | nindent 6 }}
      {{- end }}

Describe alternatives you've considered.

N/A

Additional context.

No response

Activity

  1. changed the title [-]prometheus-json-exporter: Service Monitor's additionalMetricsRelabels should support more complex relabeling features[/-] [+][prometheus-json-exporter] additionalMetricsRelabels: support full relabeling spec (regex, sourceLabels, actions)[/+] on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions