feat(alerting): add slack/email support for execution errors

This commit is contained in:
bergquist
2016-08-31 15:55:01 +02:00
parent 4619a05f43
commit 7ddd625e9d
5 changed files with 52 additions and 30 deletions

View File

@@ -54,7 +54,7 @@ func (this *EmailNotifier) Notify(context *alerting.EvalContext) {
"State": context.Rule.State,
"Name": context.Rule.Name,
"Severity": context.Rule.Severity,
"SeverityColor": context.GetColor(),
"SeverityColor": context.GetStateModel().Color,
"Message": context.Rule.Message,
"RuleUrl": ruleUrl,
"ImageLink": context.ImagePublicUrl,

View File

@@ -61,13 +61,26 @@ func (this *SlackNotifier) Notify(context *alerting.EvalContext) {
}
}
if context.Error != nil {
fields = append(fields, map[string]interface{}{
"title": "Error message",
"value": context.Error.Error(),
"short": false,
})
}
message := ""
if context.Rule.State != m.AlertStateOK { //dont add message when going back to alert state ok.
message = context.Rule.Message
}
body := map[string]interface{}{
"attachments": []map[string]interface{}{
{
"color": context.GetColor(),
"color": context.GetStateModel().Color,
"title": context.GetNotificationTitle(),
"title_link": ruleUrl,
"text": context.Rule.Message,
"text": message,
"fields": fields,
"image_url": context.ImagePublicUrl,
"footer": "Grafana v" + setting.BuildVersion,