From 638f41c21561063a6d60816bfd8507bdf0a65c3d Mon Sep 17 00:00:00 2001 From: George Robinson Date: Mon, 7 Aug 2023 11:31:28 +0100 Subject: [PATCH] Log the GroupKey and alerts in retry (#3438) 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. Signed-off-by: George Robinson --- notify/notify.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/notify/notify.go b/notify/notify.go index eef57fa2..0364a049 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -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++ @@ -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 }