From a4335d5e728287f8e055c2c4020f5f6b9928a55b Mon Sep 17 00:00:00 2001 From: Melchior MOULIN Date: Tue, 4 Feb 2020 14:32:43 +0100 Subject: [PATCH] Add slack channel when logging error. Signed-off-by: Melchior MOULIN --- notify/slack/slack.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/notify/slack/slack.go b/notify/slack/slack.go index 45a087195e..edbfdaf3be 100644 --- a/notify/slack/slack.go +++ b/notify/slack/slack.go @@ -17,6 +17,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "net/http" "github.com/go-kit/kit/log" @@ -183,5 +184,9 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) // Only 5xx response codes are recoverable and 2xx codes are successful. // https://api.slack.com/incoming-webhooks#handling_errors // https://api.slack.com/changelog/2016-05-17-changes-to-errors-for-incoming-webhooks - return n.retrier.Check(resp.StatusCode, resp.Body) + retry, err := n.retrier.Check(resp.StatusCode, resp.Body) + if err != nil { + err = fmt.Errorf("%v on slack channel: %s", err, req.Channel) + } + return retry, err }