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

Improve template to handle empty group labels #2794

Merged
merged 5 commits into from
Aug 17, 2023

Conversation

Konstantinov-Innokentii
Copy link
Member

@Konstantinov-Innokentii Konstantinov-Innokentii commented Aug 15, 2023

– Fix error with missing "groupLabels" or "alertname"
– Support rendering alerts from migrated legacy alertmanagers

@Konstantinov-Innokentii Konstantinov-Innokentii requested a review from a team August 15, 2023 09:21
{% if severity %}
{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%}
Severity: {{ severity }} {{ severity_emoji }}
{% endif %}

{%- set status = payload.status | default("Unknown") %}
{%- set status = payload.get("status", "Unknown") %}
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, what is the difference here? I think previous version is more straightforward and clear for non-python developers

Copy link
Member Author

Choose a reason for hiding this comment

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

Just aligned it with other .getusages. ( It was used in previous templates also)

{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %}
Status: {{ status }} {{ status_emoji }} (on the source)
{% if status == "firing" %}
{% if status == "firing" and payload.numFiring %}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add check for numResolved?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm checking the numFiring here to not to render empty ':', since alerts from migrated legacy alertmanager have no numFiring field. I'm still thinking how to do it better.

Copy link
Contributor

@iskhakov iskhakov left a comment

Choose a reason for hiding this comment

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

overall looks good to me, see minor comments

@Konstantinov-Innokentii Konstantinov-Innokentii added the pr:no public docs Added to a PR that does not require public documentation updates label Aug 17, 2023
@Konstantinov-Innokentii Konstantinov-Innokentii added this pull request to the merge queue Aug 17, 2023
Merged via the queue into dev with commit a6be2ca Aug 17, 2023
25 checks passed
@Konstantinov-Innokentii Konstantinov-Innokentii deleted the better_default_am_template branch August 17, 2023 07:56
Copy link
Contributor

@joeyorlando joeyorlando left a comment

Choose a reason for hiding this comment

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

is there any way to add some sort of integration tests for these template changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants