Skip to content

fix(relabel): stop randomly dropping labels - #207

Open
fdegiuli wants to merge 1 commit into
grafana:mainfrom
fdegiuli:fix_relabel
Open

fdegiuli wants to merge 1 commit into
grafana:mainfrom
fdegiuli:fix_relabel

Conversation

@fdegiuli

@fdegiuli fdegiuli commented Aug 28, 2026

Copy link
Copy Markdown

applyRelabelConfigs builds its input by ranging over a model.LabelSet, which is a map, so the order is random.
relabel.Process assumes sorted input when it resolves source_labels so on some orderings the lookup misses,
resolves empty, and the rule silently no-ops.

Impact: any rule using source_labels is intermittently skipped, with no error — the target label is just absent.
In our deployment this dropped service_name on ~30% of CloudWatch events.

There's an existing comment in main.go that calls out this requirement, but builder.Sort() was never actually called.

This PR just adds that missing call to Sort()

Added a tiny test that verifies the fix.

Likely also fixes #94 (labeldrop missing some matching labels)

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Signed commits report

1 of 1 commit between main and fix_relabel could not be fully verified:

Commit Author Reason Message
7688b5fd Federico De Giuli unknown_key bugfix: Make relabel application deterministic

This repository requires all commits to be signed. See GitHub docs on commit signature verification.

@cla-assistant

cla-assistant Bot commented Aug 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Aug 28, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Federico De Giuli seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@fdegiuli
fdegiuli force-pushed the fix_relabel branch 2 times, most recently from c39e8b0 to 1d63d25 Compare August 28, 2026 19:07
@fdegiuli fdegiuli changed the title bugfix(relabel): sort labels before relabel.Process fix(relabel): sort labels before relabel.Process Aug 28, 2026
@fdegiuli fdegiuli changed the title fix(relabel): sort labels before relabel.Process fix(relabel): stop randomly dropping labels Sep 2, 2026
@philiplinell

Copy link
Copy Markdown

I am planning to map CloudWatch log-groups to service labels using relabeling, so this fix would help. Thanks for addressing it!
Hopefully it can be merged and released soon.

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.

labeldrop doesn't seem to drop all matching labels

2 participants