From 2a94f76244adc2834ad694fded5619fcb9c78788 Mon Sep 17 00:00:00 2001 From: TwiN Date: Fri, 17 May 2024 18:18:06 -0400 Subject: [PATCH] fix(alerting): Make sure alert is triggered before attempting to persist it to the database Related to #764 and #679 --- watchdog/alerting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/watchdog/alerting.go b/watchdog/alerting.go index e02d1086..6fd7a246 100644 --- a/watchdog/alerting.go +++ b/watchdog/alerting.go @@ -65,7 +65,7 @@ func handleAlertsToResolve(ep *endpoint.Endpoint, result *endpoint.Result, alert ep.NumberOfSuccessesInARow++ for _, endpointAlert := range ep.Alerts { isStillBelowSuccessThreshold := endpointAlert.SuccessThreshold > ep.NumberOfSuccessesInARow - if isStillBelowSuccessThreshold && endpointAlert.IsEnabled() { + if isStillBelowSuccessThreshold && endpointAlert.IsEnabled() && endpointAlert.Triggered { // Persist NumberOfSuccessesInARow if err := store.Get().UpsertTriggeredEndpointAlert(ep, endpointAlert); err != nil { log.Printf("[watchdog.handleAlertsToResolve] Failed to update triggered endpoint alert for endpoint with key=%s: %s", ep.Key(), err.Error())