diff --git a/emails/templates/ng_alert_notification.html b/emails/templates/ng_alert_notification.html index 2efb616852b..7eb44968824 100644 --- a/emails/templates/ng_alert_notification.html +++ b/emails/templates/ng_alert_notification.html @@ -1,10 +1,10 @@ [[Subject .Subject "[[.Title]]"]] @@ -28,73 +28,89 @@ + + [[ if gt (len .Alerts.Firing) 0 ]] + + [[ else ]] + + [[ end ]] + + @@ -115,8 +131,8 @@
+ [[ .Alerts | len ]] alert[[ if gt (len .Alerts) 1 ]]s[[ end ]] for + [[ range .GroupLabels.SortedPairs ]] + [[ .Name ]]=[[ .Value ]] + [[ end ]] + + [[ .Alerts | len ]] alert[[ if gt (len .Alerts) 1 ]]s[[ end ]] for + [[ range .GroupLabels.SortedPairs ]] + [[ .Name ]]=[[ .Value ]] + [[ end ]] +
- +
+ [[ if gt (len .Alerts.Firing) 0 ]] - [[ if gt (len .Alerts.Firing) 0 ]] - + + [[ end ]] + [[ range .Alerts.Firing ]] + + + - + + [[ end ]] + + + + [[ end ]] + [[ range .Alerts.Resolved ]] + + + + + + + + + [[ end ]]
- [[ else ]] - - [[ end ]]. - [[ .Alerts | len ]] alert[[ if gt (len .Alerts) 1 ]]s[[ end ]] for - [[ range .GroupLabels.SortedPairs ]] - [[ .Name ]]=[[ .Value ]] - [[ end ]] + +
([[ .Alerts.Firing | len ]]) Firing
+
+
Labels
+
+ [[ if gt (len .Annotations) 0 ]]
Annotations
[[ end ]]
- - [[ if gt (len .Alerts.Firing) 0 ]] - - - - [[ end ]] - [[ range .Alerts.Firing ]] - - - - [[ end ]] + + + + [[ end ]] - [[ if gt (len .Alerts.Resolved) 0 ]] - [[ if gt (len .Alerts.Firing) 0 ]] - - - - [[ end ]] - - - - [[ end ]] - [[ range .Alerts.Resolved ]] - - - - [[ end ]] -
- ([[ .Alerts.Firing | len ]]) Firing -
- Labels
- [[ range .Labels.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] - [[ if gt (len .Annotations) 0 ]]Annotations
[[ end ]] - [[ range .Annotations.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] - Source
-
+ [[ range .Labels.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] + Source
+
+ [[ range .Annotations.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] +
-
-
-
-
- ([[ .Alerts.Resolved | len ]]) Resolved -
- Labels
- [[ range .Labels.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] - [[ if gt (len .Annotations) 0 ]]Annotations
[[ end ]] - [[ range .Annotations.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] - Source
-
+ [[ if gt (len .Alerts.Resolved) 0 ]] + [[ if gt (len .Alerts.Firing) 0 ]] +
+
+
+
+
([[ .Alerts.Resolved | len ]]) Resolved
+
+
Labels
+
+ [[ if gt (len .Annotations) 0 ]]
Annotations
[[ end ]] +
+ [[ range .Labels.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] + Source
+
+ [[ range .Annotations.SortedPairs ]][[ .Name ]] = [[ .Value ]]
[[ end ]] +
- - + +
diff --git a/pkg/services/ngalert/notifier/channels/email.go b/pkg/services/ngalert/notifier/channels/email.go index 157d6533990..9ecd14ee5cd 100644 --- a/pkg/services/ngalert/notifier/channels/email.go +++ b/pkg/services/ngalert/notifier/channels/email.go @@ -103,7 +103,7 @@ func getTitleFromTemplateData(data *template.Data) string { if data.Status == string(model.AlertFiring) { title += fmt.Sprintf(":%d", len(data.Alerts.Firing())) } - title += "]" + strings.Join(data.GroupLabels.SortedPairs().Values(), " ") + " " + title += "] " + strings.Join(data.GroupLabels.SortedPairs().Values(), " ") + " " if len(data.CommonLabels) > len(data.GroupLabels) { title += "(" + strings.Join(data.CommonLabels.Remove(data.GroupLabels.Names()).Values(), " ") + ")" } diff --git a/public/emails/ng_alert_notification.html b/public/emails/ng_alert_notification.html index afdd0ed042b..06082c71b02 100644 --- a/public/emails/ng_alert_notification.html +++ b/public/emails/ng_alert_notification.html @@ -92,12 +92,21 @@ text-decoration: underline; table[class="body"] .columns { table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; } + table[class="body"] .column { + table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; + } table[class="body"] table.columns td { width: 100% !important; } + table[class="body"] .columns td.four { + width: 33.333333% !important; + } table[class="body"] .columns td.six { width: 50% !important; } + table[class="body"] .columns td.eight { + width: 66.666666% !important; + } table[class="body"] .columns td.twelve { width: 100% !important; } @@ -227,73 +236,89 @@ text-decoration: underline;
+ + {{ if gt (len .Alerts.Firing) 0 }} + + {{ else }} + + {{ end }} + + @@ -314,8 +339,8 @@ text-decoration: underline;
+ {{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for + {{ range .GroupLabels.SortedPairs }} + {{ .Name }}={{ .Value }} + {{ end }} + + {{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for + {{ range .GroupLabels.SortedPairs }} + {{ .Name }}={{ .Value }} + {{ end }} +
- +
+ {{ if gt (len .Alerts.Firing) 0 }} - {{ if gt (len .Alerts.Firing) 0 }} - + + {{ end }} + {{ range .Alerts.Firing }} + + + - + + {{ end }} + + + + {{ end }} + {{ range .Alerts.Resolved }} + + + + + + + + + {{ end }}
- {{ else }} - - {{ end }}. - {{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for - {{ range .GroupLabels.SortedPairs }} - {{ .Name }}={{ .Value }} - {{ end }} + +
({{ .Alerts.Firing | len }}) Firing
+
+
Labels
+
+ {{ if gt (len .Annotations) 0 }}
Annotations
{{ end }}
- - {{ if gt (len .Alerts.Firing) 0 }} - - - - {{ end }} - {{ range .Alerts.Firing }} - - - - {{ end }} + + + + {{ end }} - {{ if gt (len .Alerts.Resolved) 0 }} - {{ if gt (len .Alerts.Firing) 0 }} - - - - {{ end }} - - - - {{ end }} - {{ range .Alerts.Resolved }} - - - - {{ end }} -
- ({{ .Alerts.Firing | len }}) Firing -
- Labels
- {{ range .Labels.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} - {{ if gt (len .Annotations) 0 }}Annotations
{{ end }} - {{ range .Annotations.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} - Source
-
+ {{ range .Labels.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} + Source
+
+ {{ range .Annotations.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} +
-
-
-
-
- ({{ .Alerts.Resolved | len }}) Resolved -
- Labels
- {{ range .Labels.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} - {{ if gt (len .Annotations) 0 }}Annotations
{{ end }} - {{ range .Annotations.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} - Source
-
+ {{ if gt (len .Alerts.Resolved) 0 }} + {{ if gt (len .Alerts.Firing) 0 }} +
+
+
+
+
({{ .Alerts.Resolved | len }}) Resolved
+
+
Labels
+
+ {{ if gt (len .Annotations) 0 }}
Annotations
{{ end }} +
+ {{ range .Labels.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} + Source
+
+ {{ range .Annotations.SortedPairs }}{{ .Name }} = {{ .Value }}
{{ end }} +
- - + +