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 the logic to trucate fields instead of dropping alerts in the slack integration

Signed-off-by: Prashant Balachandran <pnair@redhat.com>
Signed-off-by: Sinuhe Tellez <dubyte@gmail.com>
  • Loading branch information
Prashant Balachandran authored and dubyte committed Jan 26, 2022
1 parent 6fda5ae commit a70b893
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

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 {
key, err := notify.ExtractGroupKey(ctx)
if err != nil {
return false, err
}
level.Debug(n.logger).Log("msg", "Truncated title", "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 a70b893

Please sign in to comment.