include error message in email notification (#8392)

This commit is contained in:
Dan Cech
2017-05-17 09:51:51 +02:00
committed by Torkel Ödegaard
parent 820671d6cc
commit 9dc220b8e2
4 changed files with 54 additions and 1 deletions
+6
View File
@@ -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": "",
+2 -1
View File
@@ -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