Skip to content

[BUGFIX] Scraping: return empty label set if sample is not to be kept#17806

Merged
bboreham merged 1 commit intoprometheus:mainfrom
marvin-roesch:fix/scrape-relabeling-keep
Jan 7, 2026
Merged

[BUGFIX] Scraping: return empty label set if sample is not to be kept#17806
bboreham merged 1 commit intoprometheus:mainfrom
marvin-roesch:fix/scrape-relabeling-keep

Conversation

@marvin-roesch
Copy link
Contributor

Which issue(s) does the PR fix:

The change introduced in #17530 caused metric relabeling configs that did not modify any labels but instead only kept a subset of series (via action: keep or action: drop) to not take effect, as the actual label set was never modified by relabel.ProcessBuilder.

This is a minimally invasive fix restoring the old behavior, mirroring what relabel.Process does.

Does this PR introduce a user-facing change?

[BUGFIX] Scraping: drop sample if relabeling config says so

@roidelapluie roidelapluie mentioned this pull request Jan 7, 2026
@roidelapluie
Copy link
Member

roidelapluie commented Jan 7, 2026

Thanks! Can we have a regression test for this?

@bboreham
Copy link
Member

bboreham commented Jan 7, 2026

I'll copy this and make a PR against the release-3.9 branch.

@marvin-roesch marvin-roesch force-pushed the fix/scrape-relabeling-keep branch from bc6c1bc to 9313b3c Compare January 7, 2026 14:57
@marvin-roesch
Copy link
Contributor Author

I have added a regression test, taking some inspiration from the other tests. If there's a better place to put it or a nicer way of going about this, let me know!

@bboreham
Copy link
Member

bboreham commented Jan 7, 2026

Thanks for the test; FWIW you don't need the whole server mechanism, you could follow the structure from a test like TestScrapeLoopFailWithInvalidLabelsAfterRelabel.

Also the test harness changed massively since 3.9.0 so I will have a bit of rewriting to do.

Signed-off-by: Marvin Rösch <marvinroesch99@gmail.com>
@marvin-roesch marvin-roesch force-pushed the fix/scrape-relabeling-keep branch from 9313b3c to fff29d3 Compare January 7, 2026 15:11
@marvin-roesch
Copy link
Contributor Author

marvin-roesch commented Jan 7, 2026

Thanks for the pointer! I have adjusted the test accordingly.

@bboreham
Copy link
Member

bboreham commented Jan 7, 2026

The release-3.9 backport is at #17807.

I'm guessing it will be fine to merge both then prefer this one when 3.9 is merged into main.

Copy link
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Thanks!

@bboreham bboreham merged commit 4f337c2 into prometheus:main Jan 7, 2026
28 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