Skip to content

Commit 2541a40

Browse files
grobinson-grafanaalexweav
authored andcommitted
Add debug logs for muted alerts (prometheus#3558)
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 <george.robinson@grafana.com>
1 parent 31d06ad commit 2541a40

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

notify/notify.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,16 +539,24 @@ func NewMuteStage(m types.Muter) *MuteStage {
539539
}
540540

541541
// Exec implements the Stage interface.
542-
func (n *MuteStage) Exec(ctx context.Context, _ log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
543-
var filtered []*types.Alert
542+
func (n *MuteStage) Exec(ctx context.Context, logger log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
543+
var (
544+
filtered []*types.Alert
545+
muted []*types.Alert
546+
)
544547
for _, a := range alerts {
545548
// TODO(fabxc): increment total alerts counter.
546549
// Do not send the alert if muted.
547-
if !n.muter.Mutes(a.Labels) {
550+
if n.muter.Mutes(a.Labels) {
551+
muted = append(muted, a)
552+
} else {
548553
filtered = append(filtered, a)
549554
}
550555
// TODO(fabxc): increment muted alerts counter if muted.
551556
}
557+
if len(muted) > 0 {
558+
level.Debug(logger).Log("msg", "Notifications will not be sent for muted alerts", "alerts", fmt.Sprintf("%v", muted))
559+
}
552560
return ctx, filtered, nil
553561
}
554562

0 commit comments

Comments
 (0)