Skip to content

Commit

Permalink
Add debug logs for muted alerts (#3558)
Browse files Browse the repository at this point in the history
This commit adds debug logs to MuteStage that logs when an alert
is muted. This can help operators root cause missing notifications
when alerts are silenced by mistake or purpose but then forgotten
about.

Signed-off-by: George Robinson <[email protected]>
  • Loading branch information
grobinson-grafana authored Oct 24, 2023
1 parent 280a742 commit d250132
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,16 +518,24 @@ func NewMuteStage(m types.Muter) *MuteStage {
}

// Exec implements the Stage interface.
func (n *MuteStage) Exec(ctx context.Context, _ log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
var filtered []*types.Alert
func (n *MuteStage) Exec(ctx context.Context, logger log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
var (
filtered []*types.Alert
muted []*types.Alert
)
for _, a := range alerts {
// TODO(fabxc): increment total alerts counter.
// Do not send the alert if muted.
if !n.muter.Mutes(a.Labels) {
if n.muter.Mutes(a.Labels) {
muted = append(muted, a)
} else {
filtered = append(filtered, a)
}
// TODO(fabxc): increment muted alerts counter if muted.
}
if len(muted) > 0 {
level.Debug(logger).Log("msg", "Notifications will not be sent for muted alerts", "alerts", fmt.Sprintf("%v", muted))
}
return ctx, filtered, nil
}

Expand Down

0 comments on commit d250132

Please sign in to comment.