Skip to content

Commit

Permalink
adding max_alerts parameter to slack webhook config
Browse files Browse the repository at this point in the history
correcting formatting errors

Signed-off-by: Prashant Balachandran <pnair@redhat.com>

correcting the logic to trucate fields instead of dropping alerts in the slack integration
  • Loading branch information
Prashant Balachandran committed Dec 3, 2021
1 parent e2a1011 commit 733759b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion notify/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/go-kit/log/level"
"io/ioutil"
"net/http"

Expand Down Expand Up @@ -92,13 +93,22 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
tmplText = notify.TmplText(n.tmpl, data, &err)
)
var markdownIn []string
key, err := notify.ExtractGroupKey(ctx)

if err != nil {
return false, err
}
if len(n.conf.MrkdwnIn) == 0 {
markdownIn = []string{"fallback", "pretext", "text"}
} else {
markdownIn = n.conf.MrkdwnIn
}
title, truncated := notify.Truncate(tmplText(n.conf.Title), 1024)
if truncated {
level.Debug(n.logger).Log("msg", "Truncated text", "text", title, "key", key)
}
att := &attachment{
Title: tmplText(n.conf.Title),
Title: title,
TitleLink: tmplText(n.conf.TitleLink),
Pretext: tmplText(n.conf.Pretext),
Text: tmplText(n.conf.Text),
Expand Down

0 comments on commit 733759b

Please sign in to comment.