include error message in email notification (#8392)
This commit is contained in:
committed by
Torkel Ödegaard
parent
820671d6cc
commit
9dc220b8e2
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user