From 720b5b3b6515c72f98c957b2f2c9bbc4aedec7e5 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Tue, 9 May 2023 19:50:24 +0200 Subject: [PATCH] Alerting: Omit "description" and "summary" from default email template annotations (#68122) --- .github/CODEOWNERS | 2 +- .../partials/alerting/instance_details.mjml | 111 +++++------------- public/emails/ng_alert_notification.html | 88 ++++---------- 3 files changed, 58 insertions(+), 143 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5ece762b8ff..d0da194624f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -433,7 +433,6 @@ lerna.json @grafana/frontend-ops /public/app/types/ @grafana/grafana-frontend-platform /public/dashboards/ @grafana/dashboards-squad /public/fonts/ @grafana/alerting-squad-frontend -/public/emails/ @grafana/grafana-frontend-platform /public/gazetteer/ @ryantxu /public/img/ @grafana/grafana-frontend-platform /public/lib/ @grafana/grafana-frontend-platform @@ -618,6 +617,7 @@ embed.go @grafana/grafana-as-code /docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @grafanabot /pkg/services/featuremgmt/toggles_gen.csv @grafanabot /pkg/services/featuremgmt/toggles_gen.go @grafanabot +/public/emails/ @grafanabot # Conf /conf/defaults.ini @torkelo diff --git a/emails/templates/partials/alerting/instance_details.mjml b/emails/templates/partials/alerting/instance_details.mjml index 26a4bbd7856..458124dd974 100644 --- a/emails/templates/partials/alerting/instance_details.mjml +++ b/emails/templates/partials/alerting/instance_details.mjml @@ -1,71 +1,47 @@ - - {{ if .ImageURL }} - +{{ if .ImageURL }} - - {{ end }} - +{{ end }} - - {{ if .EmbeddedImage }} - +{{ if .EmbeddedImage }} - - {{ end }} - +{{ end }} - - {{ if .Annotations.summary }} - + {{ if .Annotations.summary }} Summary - - {{- .Annotations.summary -}} - - - {{ end }} - + {{- .Annotations.summary -}} + {{ end }} - - {{ if .Annotations.description }} - + {{ if .Annotations.description }} Description - - {{ range $line := (splitList "\n" .Annotations.description) }} - + {{ range $line := (splitList "\n" .Annotations.description) }} {{ $line }}
- - {{ end }} - + {{ end }}
- - {{ end }} - + {{ end }}
- - {{ if .Values }} - +{{ if .Values }} @@ -76,80 +52,56 @@ - - {{ range $refID, $value := .Values }} - + {{ range $refID, $value := .Values }} {{ $refID }}={{ $value }}  - - {{ end }} - + {{ end }} - - {{ end }} - +{{ end }} - - {{ if .Labels.SortedPairs }} - + {{ if .Labels.SortedPairs }} Labels - - {{ range .Labels.SortedPairs }} - + {{ range .Labels.SortedPairs }} {{ .Name }} - - {{ .Value }} - + {{ .Value }} - - {{ end }} - + {{ end }} - - {{ end }} - + {{ end }} - - - {{ if .Annotations.SortedPairs }} - + + {{ if (without .Annotations.SortedPairs.Names "description" "summary") }} Annotations - - {{ range .Annotations.SortedPairs }} - + {{ range .Annotations.SortedPairs }} + {{ if and (ne .Name "description") (ne .Name "summary") }} {{ .Name }} - - {{ .Value }} - + {{ .Value }} - - {{ end }} - + {{ end }} + {{ end }} - - {{ end }} - + {{ end }} @@ -178,9 +130,7 @@ {{ end }} {{ if .PanelURL }} - - View panel - + View panel {{ end }} @@ -189,7 +139,8 @@ - Observed {{ ago .StartsAt }} before this notification was delivered, at {{ .StartsAt }} + Observed {{ ago .StartsAt }} before this notification was delivered, at + {{ .StartsAt }} diff --git a/public/emails/ng_alert_notification.html b/public/emails/ng_alert_notification.html index 92e98369e9b..3dcf73630d8 100644 --- a/public/emails/ng_alert_notification.html +++ b/public/emails/ng_alert_notification.html @@ -470,13 +470,9 @@
- - {{ range $line := (splitList "\n" .Annotations.description) }} - + {{ range $line := (splitList "\n" .Annotations.description) }} {{ $line }}
- - {{ end }} - + {{ end }}
@@ -533,12 +529,8 @@
- - {{ range $refID, $value := .Values }} - - {{ $refID }}={{ $value }}  - {{ end }} - + {{ range $refID, $value := .Values }} + {{ $refID }}={{ $value }}  {{ end }}
@@ -576,24 +568,18 @@ - - {{ range .Labels.SortedPairs }} - + {{ range .Labels.SortedPairs }} - + - - {{ end }} - + {{ end }}
{{ .Name }} - {{ .Value }} - {{ .Value }}
- {{ end }}{{ if .Annotations.SortedPairs }} + {{ end }}{{ if (without .Annotations.SortedPairs.Names "description" "summary") }}
Annotations
@@ -602,20 +588,16 @@ - - {{ range .Annotations.SortedPairs }} - + {{ range .Annotations.SortedPairs }} + {{ if and (ne .Name "description") (ne .Name "summary") }} - + - - {{ end }} - + {{ end }} + {{ end }}
{{ .Name }} - {{ .Value }} - {{ .Value }}
@@ -979,13 +961,9 @@
- - {{ range $line := (splitList "\n" .Annotations.description) }} - + {{ range $line := (splitList "\n" .Annotations.description) }} {{ $line }}
- - {{ end }} - + {{ end }}
@@ -1042,12 +1020,8 @@
- - {{ range $refID, $value := .Values }} - - {{ $refID }}={{ $value }}  - {{ end }} - + {{ range $refID, $value := .Values }} + {{ $refID }}={{ $value }}  {{ end }}
@@ -1085,24 +1059,18 @@ - - {{ range .Labels.SortedPairs }} - + {{ range .Labels.SortedPairs }} - + - - {{ end }} - + {{ end }}
{{ .Name }} - {{ .Value }} - {{ .Value }}
- {{ end }}{{ if .Annotations.SortedPairs }} + {{ end }}{{ if (without .Annotations.SortedPairs.Names "description" "summary") }}
Annotations
@@ -1111,20 +1079,16 @@ - - {{ range .Annotations.SortedPairs }} - + {{ range .Annotations.SortedPairs }} + {{ if and (ne .Name "description") (ne .Name "summary") }} - + - - {{ end }} - + {{ end }} + {{ end }}
{{ .Name }} - {{ .Value }} - {{ .Value }}