mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 10:50:37 -06:00
feat(alerting): slack notification improvements, #5679
This commit is contained in:
parent
01da3f6cb2
commit
f9a28d3306
@ -54,7 +54,6 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||
Value: reducedValue,
|
||||
})
|
||||
context.Firing = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,16 @@ func (this *SlackNotifier) Notify(context *alerting.EvalContext) {
|
||||
}
|
||||
|
||||
fields := make([]map[string]interface{}, 0)
|
||||
for _, evt := range context.Events {
|
||||
fieldLimitCount := 4
|
||||
for index, evt := range context.Events {
|
||||
fields = append(fields, map[string]interface{}{
|
||||
"title": evt.Metric,
|
||||
"value": evt.Value,
|
||||
"short": true,
|
||||
})
|
||||
if index > fieldLimitCount {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
body := map[string]interface{}{
|
||||
@ -66,9 +71,9 @@ func (this *SlackNotifier) Notify(context *alerting.EvalContext) {
|
||||
"title": "[" + context.GetStateText() + "] " + rule.Name,
|
||||
"title_link": ruleLink,
|
||||
// "text": "Optional text that appears within the attachment",
|
||||
"fields": fields,
|
||||
"image_url": "http://my-website.com/path/to/image.jpg",
|
||||
"thumb_url": "http://example.com/path/to/thumb.png",
|
||||
"fields": fields,
|
||||
// "image_url": "http://my-website.com/path/to/image.jpg",
|
||||
// "thumb_url": "http://example.com/path/to/thumb.png",
|
||||
"footer": "Grafana v4.0.0",
|
||||
"footer_icon": "http://grafana.org/assets/img/fav32.png",
|
||||
"ts": time.Now().Unix(),
|
||||
|
Loading…
Reference in New Issue
Block a user