From fb7a6c07640eaf575fc09f5f5fb940a4da129f3a Mon Sep 17 00:00:00 2001 From: bergquist Date: Sat, 13 Aug 2016 12:13:32 +0200 Subject: [PATCH] feat(alerting): list all series in alert email --- emails/templates/alert_notification.html | 39 ++++++++++++++++++- pkg/services/alerting/notifiers/email.go | 2 + .../send_email_integration_test.go | 16 ++++++-- public/emails/alert_notification.html | 39 ++++++++++++++++++- 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/emails/templates/alert_notification.html b/emails/templates/alert_notification.html index 52f0210e4ca..cbac962a95a 100644 --- a/emails/templates/alert_notification.html +++ b/emails/templates/alert_notification.html @@ -6,7 +6,7 @@
-

[[.Title]]

+

[[.Title]]

@@ -20,12 +20,46 @@
-

[[.Message]]

+

[[.Message]]

+ + +[[if ne .State "ok" ]] + + + + +
+
+ + + + + + [[range .Events]] + + + + + [[end]] +
+ Metric name + + Value +
+ [[.Metric]] + + [[.Value]] +
+
+
+[[end]] + +
@@ -39,6 +73,7 @@
+ +
diff --git a/pkg/services/alerting/notifiers/email.go b/pkg/services/alerting/notifiers/email.go index 913d1262a6e..fb2af7fa47a 100644 --- a/pkg/services/alerting/notifiers/email.go +++ b/pkg/services/alerting/notifiers/email.go @@ -55,9 +55,11 @@ func (this *EmailNotifier) Notify(context *alerting.EvalContext) { "Name": context.Rule.Name, "Severity": context.Rule.Severity, "SeverityColor": context.GetColor(), + "Message": context.Rule.Message, "RuleUrl": ruleUrl, "ImageLink": context.ImagePublicUrl, "AlertPageUrl": setting.AppUrl + "alerting", + "Events": context.Events, }, To: this.Addresses, Template: "alert_notification.html", diff --git a/pkg/services/notifications/send_email_integration_test.go b/pkg/services/notifications/send_email_integration_test.go index fdde2f5d4b2..b91cc178240 100644 --- a/pkg/services/notifications/send_email_integration_test.go +++ b/pkg/services/notifications/send_email_integration_test.go @@ -34,12 +34,22 @@ func TestEmailIntegrationTest(t *testing.T) { "Title": "[CRITICAL] Imaginary timeserie alert", "State": "Firing", "Name": "Imaginary timeserie alert", - "Severity": "Critical", + "Severity": "ok", + "SeverityColor": "#D63232", "Message": "Alert message that will support markdown in some distant future.", "RuleUrl": "http://localhost:3000/dashboard/db/graphite-dashboard", - "AlertPageUrl": "http://localhost:3000/alerting", "ImageLink": "http://localhost:3000/render/dashboard-solo/db/graphite-dashboard?panelId=1&from=1471008499616&to=1471012099617&width=1000&height=500", - "SeverityColor": "#D63232", + "AlertPageUrl": "http://localhost:3000/alerting", + "Events": []map[string]string{ + { + "Metric": "desktop", + "Value": "40", + }, + { + "Metric": "mobile", + "Value": "20", + }, + }, }, To: []string{"asdf@asdf.com "}, Template: "alert_notification.html", diff --git a/public/emails/alert_notification.html b/public/emails/alert_notification.html index fccd0559500..75e1e21a9c3 100644 --- a/public/emails/alert_notification.html +++ b/public/emails/alert_notification.html @@ -121,7 +121,7 @@ color: #FFFFFF !important;
-

{{.Title}}

+

{{.Title}}

@@ -135,12 +135,46 @@ color: #FFFFFF !important;
-

{{.Message}}

+

{{.Message}}

+ +{{if ne .State "ok" }} + + + + +
+
+ + + + + + {{range .Events}} + + + + + {{end}} +
+ Metric name + + Value +
+ {{.Metric}} + + {{.Value}} +
+
+
+{{end}} + +
@@ -154,6 +188,7 @@ color: #FFFFFF !important;
+