Skip to content

Commit 44ac80f

Browse files
Add duration to the notify success message
This commit updates Alertmanager to add a duration to the notify success message. It complements the existing histogram to offer fine-grained information about notification attempts. This can be useful when debuggin duplicate notifications, for example, when the duration exceeds peer_timeout. Signed-off-by: George Robinson <george.robinson@grafana.com>
1 parent acb5840 commit 44ac80f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

notify/notify.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
792792
case <-tick.C:
793793
now := time.Now()
794794
retry, err := r.integration.Notify(ctx, sent...)
795-
r.metrics.notificationLatencySeconds.WithLabelValues(r.labelValues...).Observe(time.Since(now).Seconds())
795+
dur := time.Since(now)
796+
r.metrics.notificationLatencySeconds.WithLabelValues(r.labelValues...).Observe(dur.Seconds())
796797
r.metrics.numNotificationRequestsTotal.WithLabelValues(r.labelValues...).Inc()
797798
if err != nil {
798799
r.metrics.numNotificationRequestsFailedTotal.WithLabelValues(r.labelValues...).Inc()
@@ -813,7 +814,7 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
813814
lvl = level.Debug(log.With(l, "alerts", fmt.Sprintf("%v", alerts)))
814815
}
815816

816-
lvl.Log("msg", "Notify success", "attempts", i)
817+
lvl.Log("msg", "Notify success", "attempts", i, "duration", dur)
817818
return ctx, alerts, nil
818819
}
819820
case <-ctx.Done():

0 commit comments

Comments
 (0)