From f9a28d330637301878fc897f845f2c1345c5611a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 29 Jul 2016 13:41:42 +0200 Subject: [PATCH] feat(alerting): slack notification improvements, #5679 --- pkg/services/alerting/conditions/query.go | 1 - pkg/services/alerting/notifiers/slack.go | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/services/alerting/conditions/query.go b/pkg/services/alerting/conditions/query.go index 60312846b10..f76ccf608b0 100644 --- a/pkg/services/alerting/conditions/query.go +++ b/pkg/services/alerting/conditions/query.go @@ -54,7 +54,6 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) { Value: reducedValue, }) context.Firing = true - break } } } diff --git a/pkg/services/alerting/notifiers/slack.go b/pkg/services/alerting/notifiers/slack.go index 570c10cb13a..5dcac06f6dc 100644 --- a/pkg/services/alerting/notifiers/slack.go +++ b/pkg/services/alerting/notifiers/slack.go @@ -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(),