From a217e162a8471339c11fc3dfae73c854503f435a Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 29 May 2017 14:07:05 +0200 Subject: [PATCH] Do not expose resolved alerts & do not send resolved if never firing (#820) Do not expose resolved alerts on the /alerts endpoint. Do not send resolved alerts to receivers if the alerts have never been fired before. --- api/api.go | 5 +++++ notify/notify.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 1ada2d42..edcb15f5 100644 --- a/api/api.go +++ b/api/api.go @@ -300,6 +300,11 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) { continue } + // Continue if alert is resolved + if !a.Alert.EndsAt.IsZero() && a.Alert.EndsAt.Before(time.Now()) { + continue + } + status := api.getAlertStatus(a.Fingerprint()) if !showSilenced && len(status.SilencedBy) != 0 { diff --git a/notify/notify.go b/notify/notify.go index bd9c3b07..f848a0b5 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -474,7 +474,7 @@ func (n *DedupStage) needsUpdate(entry *nflogpb.Entry, firing, resolved map[uint // If we haven't notified about the alert group before, notify right away // unless we only have resolved alerts. if entry == nil { - return ((len(firing) > 0) || (n.sendResolved && len(resolved) > 0)), nil + return len(firing) > 0, nil } if !entry.IsFiringSubset(firing) {