Skip to content

feat(charts): support extra relabelings on control-plane PodMonitors - #15539

Open
Coder-in-a-shell wants to merge 1 commit into
linkerd:mainfrom
Coder-in-a-shell:feat/podmonitor-extra-relabelings
Open

feat(charts): support extra relabelings on control-plane PodMonitors#15539
Coder-in-a-shell wants to merge 1 commit into
linkerd:mainfrom
Coder-in-a-shell:feat/podmonitor-extra-relabelings

Conversation

@Coder-in-a-shell

Copy link
Copy Markdown

Problem

The linkerd-control-plane chart's templates/podmonitor.yaml ships a fixed set of relabelings on each of its three PodMonitors, and no metricRelabelings at all. Operators who need to add their own rules — the motivating case in #15212 is dropping a pod that a second, non-Prometheus scraper (vmagent) already covers, to avoid duplicate timeseries — have no way to do it from values and must fork the chart.

Solution

Adds extraRelabelings and extraMetricRelabelings under podMonitor.controller, podMonitor.serviceMirror and podMonitor.proxy.

This follows the shape @alpeb confirmed in #15212 (comment), and specifically the append semantics rather than a wholesale spec-override map: the extra rules land after the relabelings the chart already sets, so the labelmap/labeldrop chain that produces the expected proxy metric labels can't be replaced by accident.

Both values default to [], and the metricRelabelings block renders only when non-empty, so default output is byte-for-byte unchanged — the only golden-file churn is the two new empty keys in the linkerd-config values dump.

This is the same pattern as the two already-merged siblings on this template: podMonitor.labels (#11222) and honorTimestamps (#15080).

Validation

helm template with the exact drop rule from the issue, plus metric relabelings on all three PodMonitors, renders as intended:

podMonitor:
  enabled: true
  proxy:
    extraRelabelings:
      - sourceLabels:
          - __meta_kubernetes_namespace
          - __meta_kubernetes_pod_label_app_kubernetes_io_name
        action: drop
        regex: ^metrics;vmagent$
    extraMetricRelabelings:
      - sourceLabels: [__name__]
        action: drop
        regex: go_.*

Parsing the rendered manifests confirms placement and count for each PodMonitor:

linkerd-controller               | relabelings=4  last=pod_template_hash   | metricRelabelings=0
linkerd-multicluster-controller  | relabelings=3  last=                    | metricRelabelings=1
linkerd-proxy                    | relabelings=13 last=^metrics;vmagent$   | metricRelabelings=1

i.e. the extra rules are appended last and metricRelabelings appears only where configured. Rendering with the defaults produces output identical to main.

Also ran:

  • go test ./pkg/charts/linkerd2/... — pass
  • go test ./cli/cmd/... — pass (golden files regenerated with -update; diff is only the two new empty keys)
  • go build ./..., go vet, gofmt — clean

Fixes #15212

Signed-off-by: Sudhir Jaiswal jaiswalsudhir2944@gmail.com

Adds `extraRelabelings` and `extraMetricRelabelings` values for each of
the three PodMonitors in the linkerd-control-plane chart (controller,
serviceMirror and proxy).

Operators who need to add their own filters to the PodMonitors -- for
example, dropping a pod that a second, non-Prometheus scraper already
covers, to avoid duplicate timeseries -- currently have to fork the
chart, since the `relabelings` the chart ships are fixed and there is no
`metricRelabelings` block at all.

The extra rules are appended after the relabelings the chart already
sets rather than replacing them, so the `labelmap`/`labeldrop` chain
that produces the expected proxy metric labels stays intact. Both values
default to an empty list, and the `metricRelabelings` block is only
rendered when non-empty, so the default output is unchanged.

Fixes linkerd#15212

Signed-off-by: Sudhir Jaiswal <jaiswalsudhir2944@gmail.com>
@Coder-in-a-shell
Coder-in-a-shell requested a review from a team as a code owner July 29, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linkerd-control-plane chart: support podMonitor.extraRelabelings to filter scrape targets without forking

2 participants