Skip to content

Commit

Permalink
Log the GroupKey and alerts in retry
Browse files Browse the repository at this point in the history
This commit updates notify.go to log the GroupKey and fingerprints
of an alert at the debug level, and just the GroupKey at the
warning level should the notify attempt fail.
  • Loading branch information
grobinson-grafana committed Aug 3, 2023
1 parent 7411e54 commit 1be3f6b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,11 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
i = 0
iErr error
)

l = log.With(l, "receiver", r.groupName, "integration", r.integration.String())
if groupKey, ok := GroupKey(ctx); ok {
l = log.With(l, "aggrGroup", groupKey)
}

for {
i++
Expand Down Expand Up @@ -745,10 +749,11 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
// integration upon context timeout.
iErr = err
} else {
lvl := level.Debug(l)
if i > 1 {
lvl = level.Info(l)
lvl := level.Info(l)
if i <= 1 {
lvl = level.Debug(log.With(l, "alerts", fmt.Sprintf("%v", alerts)))
}

lvl.Log("msg", "Notify success", "attempts", i)
return ctx, alerts, nil
}
Expand Down

0 comments on commit 1be3f6b

Please sign in to comment.