From adea539b8d8bcaa1382290af442c8e2141a52357 Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 17 Jun 2016 16:43:14 +0200 Subject: [PATCH] feat(alerting): add link to panel png --- emails/templates/alert_notification.html | 6 +++-- pkg/services/alerting/notifier.go | 1 + .../notifications/notifications_test.go | 23 ++++++++++--------- public/emails/alert_notification.html | 6 +++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/emails/templates/alert_notification.html b/emails/templates/alert_notification.html index 763d05b6733..3955c3dbf1e 100644 --- a/emails/templates/alert_notification.html +++ b/emails/templates/alert_notification.html @@ -3,14 +3,16 @@ [[Subject .Subject "Grafana Alert: [ [[.State]] ] [[.Name]]" ]] Alertstate: [[.State]]
-[[.AlertPageUrl]]"
-[[.DashboardLink]]"
+[[.AlertPageUrl]]
+[[.DashboardLink]]
[[.Description]]
[[if eq .State "Ok"]] Everything is Ok [[end]] + + [[if ne .State "Ok" ]] diff --git a/pkg/services/alerting/notifier.go b/pkg/services/alerting/notifier.go index a7214311d97..f9462038b50 100644 --- a/pkg/services/alerting/notifier.go +++ b/pkg/services/alerting/notifier.go @@ -64,6 +64,7 @@ func (this *EmailNotifier) Dispatch(alertResult *AlertResult) { "TriggeredAlerts": alertResult.TriggeredAlerts, "DashboardLink": grafanaUrl + "/dashboard/db/alerting", "AlertPageUrl": grafanaUrl + "/alerting", + "DashboardImage": grafanaUrl + "/render/dashboard-solo/db/alerting?from=1466169458375&to=1466171258375&panelId=1&width=1000&height=500", }, To: []string{this.To}, Template: "alert_notification.html", diff --git a/pkg/services/notifications/notifications_test.go b/pkg/services/notifications/notifications_test.go index bbc7a6df587..3e855eea926 100644 --- a/pkg/services/notifications/notifications_test.go +++ b/pkg/services/notifications/notifications_test.go @@ -45,11 +45,12 @@ func TestNotifications(t *testing.T) { Convey("When sending reset email password", func() { cmd := &m.SendEmailCommand{ Data: map[string]interface{}{ - "Name": "Name", - "State": "Critical", - "Description": "Description", - "DashboardLink": "http://localhost:3000/dashboard/db/alerting", - "AlertPageUrl": "http://localhost:3000/alerting", + "Name": "Name", + "State": "Critical", + "Description": "Description", + "DashboardLink": "http://localhost:3000/dashboard/db/alerting", + "AlertPageUrl": "http://localhost:3000/alerting", + "DashboardImage": "http://localhost:3000/render/dashboard-solo/db/alerting?from=1466169458375&to=1466171258375&panelId=1&width=1000&height=500", "TriggeredAlerts": []testTriggeredAlert{ {Name: "desktop", State: "Critical", ActualValue: 13}, {Name: "mobile", State: "Warn", ActualValue: 5}, @@ -68,18 +69,18 @@ func TestNotifications(t *testing.T) { So(sentMsg.Body, ShouldContainSubstring, "Warn") So(sentMsg.Body, ShouldContainSubstring, "mobile") So(sentMsg.Body, ShouldContainSubstring, "desktop") - So(sentMsg.Subject, ShouldContainSubstring, "Grafana Alert: [ Critical ] ") }) Convey("given critical", func() { cmd := &m.SendEmailCommand{ Data: map[string]interface{}{ - "Name": "Name", - "State": "Warn", - "Description": "Description", - "DashboardLink": "http://localhost:3000/dashboard/db/alerting", - "AlertPageUrl": "http://localhost:3000/alerting", + "Name": "Name", + "State": "Warn", + "Description": "Description", + "DashboardLink": "http://localhost:3000/dashboard/db/alerting", + "DashboardImage": "http://localhost:3000/render/dashboard-solo/db/alerting?from=1466169458375&to=1466171258375&panelId=1&width=1000&height=500", + "AlertPageUrl": "http://localhost:3000/alerting", "TriggeredAlerts": []testTriggeredAlert{ {Name: "desktop", State: "Critical", ActualValue: 13}, {Name: "mobile", State: "Warn", ActualValue: 5}, diff --git a/public/emails/alert_notification.html b/public/emails/alert_notification.html index 1b905b8c378..4491c71a5cc 100644 --- a/public/emails/alert_notification.html +++ b/public/emails/alert_notification.html @@ -118,8 +118,8 @@ color: #FFFFFF !important; {{Subject .Subject "Grafana Alert: [ {{.State}} ] {{.Name}}" }} Alertstate: {{.State}}
-{{.AlertPageUrl}}"
-{{.DashboardLink}}"
+{{.AlertPageUrl}}
+{{.DashboardLink}}
{{.Description}}
{{if eq .State "Ok"}} @@ -127,6 +127,8 @@ Alertstate: {{.State}}
{{end}} {{if ne .State "Ok" }} + +