mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
include error message in email notification (#8392)
This commit is contained in:
parent
820671d6cc
commit
9dc220b8e2
@ -28,6 +28,29 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
[[if ne .Error "" ]]
|
||||
<table class="row" >
|
||||
<tr>
|
||||
<td class="last">
|
||||
<center>
|
||||
<table class="twelve columns" >
|
||||
<tr>
|
||||
<td class="twelve last">
|
||||
<h5 style="font-weight: bold;">Error message</h5>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="twelve last">
|
||||
<p>[[.Error]]</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
[[end]]
|
||||
|
||||
[[if ne .State "ok" ]]
|
||||
<table class="row" >
|
||||
<tr>
|
||||
|
@ -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
|
||||
|
@ -234,6 +234,29 @@ text-decoration: underline;
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{{if ne .Error "" }}
|
||||
<table class="row" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: block; padding: 0px;">
|
||||
<tr style="vertical-align: top; padding: 0;" align="left">
|
||||
<td class="last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; color: #222222; font-family: 'Open Sans', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; margin: 0; padding: 0 0px 0 0;" align="left" valign="top">
|
||||
<center style="width: 100%; min-width: 580px;">
|
||||
<table class="twelve columns" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 580px; margin: 0 auto; padding: 0;">
|
||||
<tr style="vertical-align: top; padding: 0;" align="left">
|
||||
<td class="twelve last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; width: 100%; color: #222222; font-family: 'Open Sans', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; margin: 0; padding: 0px 0px 10px;" align="left" valign="top">
|
||||
<h5 style="font-weight: bold; color: #222222; font-family: 'Open Sans', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; line-height: 1.3; word-break: normal; font-size: 18px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; margin: 0; padding: 0;" align="left">Error message</h5>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top; padding: 0;" align="left">
|
||||
<td class="twelve last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; width: 100%; color: #222222; font-family: 'Open Sans', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; margin: 0; padding: 0px 0px 10px;" align="left" valign="top">
|
||||
<p style="color: #222222; font-family: 'Open Sans', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; margin: 0 0 10px; padding: 0;" align="left">{{.Error}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{end}}
|
||||
|
||||
{{if ne .State "ok" }}
|
||||
<table class="row" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: block; padding: 0px;">
|
||||
<tr style="vertical-align: top; padding: 0;" align="left">
|
||||
|
Loading…
Reference in New Issue
Block a user