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

Alerting: Better printing of labels #63348

Merged
merged 2 commits into from Feb 16, 2023

Conversation

grobinson-grafana
Copy link
Contributor

@grobinson-grafana grobinson-grafana commented Feb 14, 2023

What is this feature?

This pull request changes how labels are printed in templates for custom annotations and labels from map[foo:bar bar:baz] to foo=bar, bar=baz. Labels are comma separated, and sorted in increasing order.

Why do we need this feature?

[Add a description of the problem the feature is trying to solve.]

Who is this feature for?

[Add information on what kind of user the feature is for.]

Which issue(s) does this PR fix?:

Fixes #63349

Special notes for your reviewer:

@grobinson-grafana grobinson-grafana added this to the 9.5.0 milestone Feb 14, 2023
@grobinson-grafana grobinson-grafana requested a review from a team as a code owner February 14, 2023 22:48
@grobinson-grafana grobinson-grafana self-assigned this Feb 14, 2023
@grobinson-grafana
Copy link
Contributor Author

This pull request is based off #63347.

Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

LGTM!
It is worth mentioning that this is used only in expanding templates in the rule's labels and annotations. Therefore, this should not have a negative effect on the notifications sent by the alertmanager. The positive effect, though, is that it will make templates like
{ $values.B.labels } to be much more readable, which is a significant improvement!

This commit changes how labels are printed in templates for custom
annotations and labels from map[foo:bar bar:baz] to foo=bar, bar=baz.
Labels are comma separated, and sorted in increasing order.
@grobinson-grafana grobinson-grafana enabled auto-merge (squash) February 16, 2023 16:26
@grobinson-grafana grobinson-grafana merged commit 0659134 into main Feb 16, 2023
@grobinson-grafana grobinson-grafana deleted the grobinson/better-print-labels branch February 16, 2023 17:04
ryantxu pushed a commit that referenced this pull request Mar 2, 2023
This commit changes how labels are printed in templates for custom
annotations and labels from map[foo:bar bar:baz] to foo=bar, bar=baz.
Labels are comma separated, and sorted in increasing order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Better default printing of $labels in custom annotations and labels
3 participants