-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Alerting: Fix ambiguous handling of equals in labels when bucketing Loki state history streams #65013
Conversation
@@ -248,7 +248,12 @@ func statesToStreams(rule history_model.RuleMeta, states []state.StateTransition | |||
labels[RuleUIDLabel] = fmt.Sprint(rule.UID) | |||
labels[GroupLabel] = fmt.Sprint(rule.Group) | |||
labels[FolderUIDLabel] = fmt.Sprint(rule.NamespaceUID) | |||
repr := labels.String() | |||
lblJsn, err := json.Marshal(labels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choice of JSON as a stable representation was somewhat arbitrary.
- Hash of labels also works and is more compact. But, we're also relying on the labels being parseable later on, so we'd need to store the labels again separately, which undoes any memory savings.
data.LabelsFromString(...)
already understands JSON, so no code changes needed on parse side.
3f57c32
to
5d83ba6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-65013-to-v9.4.x origin/v9.4.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x cc7e5ce62e314af09d59260ec385f531e88bf353
# Push it to GitHub
git push --set-upstream origin backport-65013-to-v9.4.x
git switch main
# Remove the local backport branch
git branch -D backport-65013-to-v9.4.x Then, create a pull request where the |
What is this feature?
grafana-plugin-sdk
'sdata.Labels
type is the canonical dataframe type for handling labels.Its
LabelsFromString()
andString()
methods break on labels containing=
. The format it uses is ambiguous.We also can't use prometheus Labels format, its repr is also ambiguous around equals. Grafana's labels are a superset of Prometheus labels.
With this PR, we use a stable representation.
Why do we need this feature?
Allow equals to be used without issues.
Which issue(s) does this PR fix?:
Fixes #65012
Special notes for your reviewer: