Files
grafana/emails/templates/ng_alert_notification.txt
T
Grot (@grafanabot) 2209deb0bf [v10.0.x] Alerting: Fix newlines in text/plain template (#70228)
Alerting: Fix newlines in text/plain template (#70207)

Alerting: Fix newlines in text/plain template at last
(cherry picked from commit a773b722b1)

Co-authored-by: George Robinson <george.robinson@grafana.com>
2023-06-16 12:54:30 +03:00

63 lines
1.8 KiB
Plaintext

[[- define "__default_message" -]]
You have [[ len .Alerts.Firing ]] firing alert(s), and [[ len .Alerts.Resolved ]] resolved alert(s) for [[ .GroupLabels ]]
[[ if .Alerts.Firing -]]
([[ len .Alerts.Firing ]]) FIRING
-----------
[[ template "__default_alerts_summarize" .Alerts.Firing ]]
[[- end ]]
[[- if .Alerts.Resolved ]]
([[ len .Alerts.Resolved ]]) RESOLVED
-------------
[[ template "__default_alerts_summarize" .Alerts.Resolved ]]
[[- end ]]
Go to the Alerts page: [[ .AlertPageUrl ]]
[[- end -]]
[[- define "__default_alerts_summarize" -]]
[[- range . ]]
[[ 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 -]]
[[- end -]]
[[- define "__default_alert_annotations" -]]
[[- $annotations := .Annotations -]]
[[- if index $annotations "summary" ]]
Summary: [[ index .Annotations "summary" -]]
[[- $annotations = $annotations.Remove (toStrings (list "summary")) ]]
[[- end -]]
[[- if index $annotations "description" ]]
Description: [[ index $annotations "description" -]]
[[- $annotations = $annotations.Remove (toStrings (list "description")) ]]
[[- end -]]
[[- if index $annotations "runbook_url" ]]
Runbook: [[ index $annotations "runbook_url" -]]
[[- $annotations = $annotations.Remove (toStrings (list "runbook_url")) ]]
[[- end -]]
[[- if $annotations ]]
Annotations: [[ template "__default_sorted_pairs" $annotations ]]
[[- end -]]
[[- end -]]
[[- define "__default_sorted_pairs" -]]
[[ range .SortedPairs ]]
- [[ .Name ]] = [[ .Value ]]
[[- end ]]
[[- end -]]
[[- if .Message -]]
[[ .Message ]]
[[- else -]]
[[ template "__default_message" . ]]
[[- end ]]