diff --git a/emails/templates/alert_notification.html b/emails/templates/alert_notification.html index d0d69faa106..e12fb4ea3e6 100644 --- a/emails/templates/alert_notification.html +++ b/emails/templates/alert_notification.html @@ -28,6 +28,29 @@ +[[if ne .Error "" ]] + + + + +
+
+ + + + + + + +
+
Error message
+
+

[[.Error]]

+
+
+
+[[end]] + [[if ne .State "ok" ]] diff --git a/pkg/services/alerting/notifiers/email.go b/pkg/services/alerting/notifiers/email.go index dcf71f0f99e..cdde05ba62f 100644 --- a/pkg/services/alerting/notifiers/email.go +++ b/pkg/services/alerting/notifiers/email.go @@ -69,6 +69,11 @@ func (this *EmailNotifier) Notify(evalContext *alerting.EvalContext) error { return err } + error := "" + if evalContext.Error != nil { + error = evalContext.Error.Error() + } + cmd := &m.SendEmailCommandSync{ SendEmailCommand: m.SendEmailCommand{ Subject: evalContext.GetNotificationTitle(), @@ -78,6 +83,7 @@ func (this *EmailNotifier) Notify(evalContext *alerting.EvalContext) error { "Name": evalContext.Rule.Name, "StateModel": evalContext.GetStateModel(), "Message": evalContext.Rule.Message, + "Error": error, "RuleUrl": ruleUrl, "ImageLink": "", "EmbededImage": "", diff --git a/pkg/services/alerting/test_notification.go b/pkg/services/alerting/test_notification.go index 91b3814ac7b..7dc9a150d92 100644 --- a/pkg/services/alerting/test_notification.go +++ b/pkg/services/alerting/test_notification.go @@ -2,6 +2,7 @@ package alerting import ( "context" + "fmt" "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/components/null" @@ -56,7 +57,7 @@ func createTestEvalContext(cmd *NotificationTestCommand) *EvalContext { } ctx.IsTestRun = true ctx.Firing = true - ctx.Error = nil + ctx.Error = fmt.Errorf("This is only a test") ctx.EvalMatches = evalMatchesBasedOnState() return ctx diff --git a/public/emails/alert_notification.html b/public/emails/alert_notification.html index ce8354cdff5..f8a81312643 100644 --- a/public/emails/alert_notification.html +++ b/public/emails/alert_notification.html @@ -234,6 +234,29 @@ text-decoration: underline;
+{{if ne .Error "" }} + + + + +
+
+ + + + + + + +
+
Error message
+
+

{{.Error}}

+
+
+
+{{end}} + {{if ne .State "ok" }}