Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support capitalized relabel actions to match with prometheus-operator behavior #2209

Conversation

QuentinBisson
Copy link
Contributor

PR Description

The prometheus operator ServiceMonitors, PodMonitors and Probes relabelings sections support capitalized actions like so: https://github.com/prometheus-operator/prometheus-operator/blob/ccfd2196833a350100658b9d645f0935e3b90a3d/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml#L349

The issue is prometheus itself only supports lowercase actions so the prometheus-operator maintainers added https://github.com/prometheus-operator/prometheus-operator/blob/ccfd2196833a350100658b9d645f0935e3b90a3d/pkg/prometheus/resource_selector.go#L294 to lowercase actions.

This PR aims to reproduce this as incorrect values like "Replace" actually causes alloy to panic like so:

panic: relabel: unknown relabel action type "Replace"

goroutine 906 [running]:
github.com/prometheus/prometheus/model/relabel.relabel(0xc001f343f0, 0xc00a0239a0)
        /go/pkg/mod/github.com/grafana/[email protected]/model/relabel/relabel.go:314 +0x96e
github.com/prometheus/prometheus/model/relabel.ProcessBuilder(...)
        /go/pkg/mod/github.com/grafana/[email protected]/model/relabel/relabel.go:233
github.com/prometheus/prometheus/scrape.PopulateLabels(0xc00a0239a0, 0xc003018d88, 0x0)
        /go/pkg/mod/github.com/grafana/[email protected]/scrape/target.go:445 +0x510
github.com/prometheus/prometheus/scrape.TargetsFromGroup(0xc00a134000, 0xc003018d88, 0x0, {0x0?, 0xa474900?, 0x6b?}, 0xc00a0239a0)
        /go/pkg/mod/github.com/grafana/[email protected]/scrape/target.go:571 +0x1d5
github.com/prometheus/prometheus/scrape.(*scrapePool).Sync(0xc009f3e1a0, {0xc00a0d38c0, 0x21, 0xc002980f60?})
        /go/pkg/mod/github.com/grafana/[email protected]/scrape/scrape.go:391 +0x1e6
github.com/prometheus/prometheus/scrape.(*Manager).reload.func1(0xc00365ff60?, {0xc00a0d38c0?, 0x40a2105?, 0xc00300ca80?})
        /go/pkg/mod/github.com/grafana/[email protected]/scrape/manager.go:180 +0x25
created by github.com/prometheus/prometheus/scrape.(*Manager).reload in goroutine 300
        /go/pkg/mod/github.com/grafana/prometheus@v

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Tests updated

@QuentinBisson QuentinBisson requested a review from a team as a code owner December 3, 2024 14:57
@QuentinBisson
Copy link
Contributor Author

@mattdurham do you think you could take a look at this one?

Copy link
Contributor

@dehaansa dehaansa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, but there are extra entries in the changelog.

@QuentinBisson
Copy link
Contributor Author

@dehaansa should be better now, I think I made a bad merge

@wildum wildum merged commit 9b2e3c8 into grafana:main Dec 6, 2024
15 checks passed
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.

3 participants