diff --git a/emails/templates/ng_alert_notification.txt b/emails/templates/ng_alert_notification.txt index 0848d168041..28e466d16df 100644 --- a/emails/templates/ng_alert_notification.txt +++ b/emails/templates/ng_alert_notification.txt @@ -17,17 +17,18 @@ Go to the Alerts page: [[ .AlertPageUrl ]] [[- define "__default_alerts_summarize" -]] [[- range . ]] -[[ template "__default_alert_labels" . ]] +[[- template "__default_alert_labels" . ]] [[- template "__default_alert_annotations" . ]] [[ end ]] [[- end -]] [[- define "__default_alert_labels" -]] -[[- if gt (len .Labels) 3 -]] -Labels: [[ template "__default_sorted_pairs" .Labels ]] -[[- else -]] -Labels: [[ .Labels.SortedPairs ]] -[[- end -]] +[[- $labels := .Labels -]] +[[- if index $labels "alertname" ]] +Alertname: [[ index .Labels "alertname" -]] +[[ $labels = $labels.Remove (toStrings (list "alertname")) ]] +[[- end ]] +Labels: [[ template "__default_sorted_pairs" $labels ]] [[- end -]] [[- define "__default_alert_annotations" -]] diff --git a/public/emails/ng_alert_notification.txt b/public/emails/ng_alert_notification.txt index 7db5996f3db..357a6a1ff4c 100644 --- a/public/emails/ng_alert_notification.txt +++ b/public/emails/ng_alert_notification.txt @@ -17,17 +17,18 @@ Go to the Alerts page: {{ .AlertPageUrl }} {{- define "__default_alerts_summarize" -}} {{- range . }} -{{ template "__default_alert_labels" . }} +{{- template "__default_alert_labels" . }} {{- template "__default_alert_annotations" . }} {{ end }} {{- end -}} {{- define "__default_alert_labels" -}} -{{- if gt (len .Labels) 3 -}} -Labels: {{ template "__default_sorted_pairs" .Labels }} -{{- else -}} -Labels: {{ .Labels.SortedPairs }} -{{- end -}} +{{- $labels := .Labels -}} +{{- if index $labels "alertname" }} +Alertname: {{ index .Labels "alertname" -}} +{{ $labels = $labels.Remove (toStrings (list "alertname")) }} +{{- end }} +Labels: {{ template "__default_sorted_pairs" $labels }} {{- end -}} {{- define "__default_alert_annotations" -}}