diff --git a/CHANGELOG.md b/CHANGELOG.md index a871ecbcce..19874441e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Improve default AlertManager template ([#2794](https://github.com/grafana/oncall/pull/2794)) + ### Fixed - Ignore ical cancelled events when calculating shifts ([#2776](https://github.com/grafana/oncall/pull/2776)) diff --git a/engine/config_integrations/alertmanager.py b/engine/config_integrations/alertmanager.py index bfd1f23413..79b244e6da 100644 --- a/engine/config_integrations/alertmanager.py +++ b/engine/config_integrations/alertmanager.py @@ -22,67 +22,89 @@ # Web web_title = """\ -{%- set groupLabels = payload.groupLabels.copy() -%} -{%- set alertname = groupLabels.pop('alertname') | default("") -%} - - -[{{ payload.status }}{% if payload.status == 'firing' %}:{{ payload.numFiring }}{% endif %}] {{ alertname }} {% if groupLabels | length > 0 %}({{ groupLabels|join(", ") }}){% endif %} +{% set groupLabels = payload.get("groupLabels", {}).copy() -%} +{% if "labels" in payload -%} +{# backward compatibility with legacy alertmanager integration -#} +{% set alertname = payload.get("labels", {}).get("alertname", "") -%} +{% else -%} +{% set alertname = groupLabels.pop("alertname", "") -%} +{% endif -%} + +[{{ payload.status }}{% if payload.status == 'firing' and payload.numFiring %}:{{ payload.numFiring }}{% endif %}] {{ alertname }} {% if groupLabels | length > 0 %}({{ groupLabels.values()|join(", ") }}){% endif %} """ # noqa web_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} [:book: Runbook:link:]({{ annotations.runbook_url }}) -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} [:closed_book: Runbook (internal):link:]({{ annotations.runbook_url_internal }}) -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} + +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} [View in AlertManager]({{ source_link }}) """ # Slack slack_title = """\ -{%- set groupLabels = payload.groupLabels.copy() -%} -{%- set alertname = groupLabels.pop('alertname') | default("") -%} *<{{ grafana_oncall_link }}|#{{ grafana_oncall_incident_id }} {{ web_title }}>* via {{ integration_name }} {% if source_link %} (*<{{ source_link }}|source>*) @@ -99,50 +121,71 @@ # """ slack_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} <{{ annotations.runbook_url }}|:book: Runbook:link:> -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} <{{ annotations.runbook_url_internal }}|:closed_book: Runbook (internal):link:> -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} + +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} + +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} """ # noqa: W291 @@ -155,57 +198,77 @@ sms_title = web_title # Phone -phone_call_title = """{{ payload.groupLabels|join(", ") }}""" +phone_call_title = """{{ payload.get("groupLabels", {}).values() |join(", ") }}""" # Telegram telegram_title = web_title telegram_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} :book: Runbook:link: -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} :closed_book: Runbook (internal):link: -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} + +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} View in AlertManager """ diff --git a/engine/config_integrations/grafana_alerting.py b/engine/config_integrations/grafana_alerting.py index 5def268428..3209a0fc0d 100644 --- a/engine/config_integrations/grafana_alerting.py +++ b/engine/config_integrations/grafana_alerting.py @@ -11,6 +11,7 @@ featured_tag_name = "Quick Connect" is_able_to_autoresolve = True is_demo_alert_enabled = True +based_on_alertmanager = True # Behaviour @@ -22,69 +23,91 @@ acknowledge_condition = None - +# Web web_title = """\ -{%- set groupLabels = payload.groupLabels.copy() -%} -{%- set alertname = groupLabels.pop('alertname') | default("") -%} - - -[{{ payload.status }}{% if payload.status == 'firing' %}:{{ payload.numFiring }}{% endif %}] {{ alertname }} {% if groupLabels | length > 0 %}({{ groupLabels|join(", ") }}){% endif %} +{% set groupLabels = payload.get("groupLabels", {}).copy() -%} +{% if "labels" in payload -%} +{# backward compatibility with legacy alertmanager integration -#} +{% set alertname = payload.get("labels", {}).get("alertname", "") -%} +{% else -%} +{% set alertname = groupLabels.pop("alertname", "") -%} +{% endif -%} + +[{{ payload.status }}{% if payload.status == 'firing' and payload.numFiring %}:{{ payload.numFiring }}{% endif %}] {{ alertname }} {% if groupLabels | length > 0 %}({{ groupLabels.values()|join(", ") }}){% endif %} """ # noqa web_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} [:book: Runbook:link:]({{ annotations.runbook_url }}) -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} [:closed_book: Runbook (internal):link:]({{ annotations.runbook_url_internal }}) -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} + +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} [View in AlertManager]({{ source_link }}) """ -# Slack templates +# Slack slack_title = """\ -{%- set groupLabels = payload.groupLabels.copy() -%} -{%- set alertname = groupLabels.pop('alertname') | default("") -%} *<{{ grafana_oncall_link }}|#{{ grafana_oncall_incident_id }} {{ web_title }}>* via {{ integration_name }} {% if source_link %} (*<{{ source_link }}|source>*) @@ -101,50 +124,71 @@ # """ slack_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} <{{ annotations.runbook_url }}|:book: Runbook:link:> -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} <{{ annotations.runbook_url_internal }}|:closed_book: Runbook (internal):link:> -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} + +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} + +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} """ # noqa: W291 @@ -153,59 +197,81 @@ web_image_url = None +# SMS sms_title = web_title +# Phone +phone_call_title = """{{ payload.get("groupLabels", {}).values() |join(", ") }}""" -phone_call_title = """{{ payload.groupLabels|join(", ") }}""" - +# Telegram telegram_title = web_title telegram_message = """\ -{%- set annotations = payload.commonAnnotations.copy() -%} - -{% set severity = payload.groupLabels.severity -%} -{% if severity %} -{%- set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} +{% set annotations = payload.get("commonAnnotations", {}).copy() -%} +{% set groupLabels = payload.get("groupLabels", {}) -%} +{% set commonLabels = payload.get("commonLabels", {}) -%} +{% set severity = groupLabels.severity -%} +{% set legacyLabels = payload.get("labels", {}) -%} +{% set legacyAnnotations = payload.get("annotations", {}) -%} + +{% if severity -%} +{% set severity_emoji = {"critical": ":rotating_light:", "warning": ":warning:" }[severity] | default(":question:") -%} Severity: {{ severity }} {{ severity_emoji }} -{% endif %} +{% endif -%} -{%- set status = payload.status | default("Unknown") %} -{%- set status_emoji = {"firing": ":fire:", "resolved": ":white_check_mark:"}[status] | default(":warning:") %} +{% set status = payload.get("status", "Unknown") -%} +{% 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 -%} Firing alerts – {{ payload.numFiring }} Resolved alerts – {{ payload.numResolved }} -{% endif %} +{% endif -%} {% if "runbook_url" in annotations -%} :book: Runbook:link: -{%- set _ = annotations.pop('runbook_url') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url') -%} +{% endif -%} -{%- if "runbook_url_internal" in annotations -%} +{% if "runbook_url_internal" in annotations -%} :closed_book: Runbook (internal):link: -{%- set _ = annotations.pop('runbook_url_internal') -%} -{%- endif %} +{% set _ = annotations.pop('runbook_url_internal') -%} +{% endif %} +{%- if groupLabels | length > 0 %} GroupLabels: -{%- for k, v in payload["groupLabels"].items() %} +{% for k, v in groupLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} +{% endfor %} +{% endif -%} -{% if payload["commonLabels"] | length > 0 -%} +{% if commonLabels | length > 0 -%} CommonLabels: -{%- for k, v in payload["commonLabels"].items() %} +{% for k, v in commonLabels.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} {% if annotations | length > 0 -%} Annotations: -{%- for k, v in annotations.items() %} +{% for k, v in annotations.items() -%} - {{ k }}: {{ v }} -{%- endfor %} -{% endif %} +{% endfor %} +{% endif -%} + +{# backward compatibility with legacy alertmanager integration -#} +{% if legacyLabels | length > 0 -%} +Labels: +{% for k, v in legacyLabels.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} +{% if legacyAnnotations | length > 0 -%} +Annotations: +{% for k, v in legacyAnnotations.items() -%} +- {{ k }}: {{ v }} +{% endfor %} +{% endif -%} View in AlertManager """