Alerting: rule evaluation loop to not access multiorg Alertmanager if no alerts to add (#39872)

This commit is contained in:
Yuriy Tseretyan 2021-09-30 15:07:56 -04:00 committed by GitHub
parent 29f3e175b6
commit 526961f298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -478,6 +478,11 @@ func (sch *schedule) ruleRoutine(grafanaCtx context.Context, key models.AlertRul
sch.saveAlertStates(processedStates) sch.saveAlertStates(processedStates)
alerts := FromAlertStateToPostableAlerts(processedStates, sch.stateManager, sch.appURL) alerts := FromAlertStateToPostableAlerts(processedStates, sch.stateManager, sch.appURL)
if len(alerts.PostableAlerts) == 0 {
sch.log.Debug("no alerts to put in the notifier", "org", alertRule.OrgID)
return nil
}
sch.log.Debug("sending alerts to notifier", "count", len(alerts.PostableAlerts), "alerts", alerts.PostableAlerts, "org", alertRule.OrgID) sch.log.Debug("sending alerts to notifier", "count", len(alerts.PostableAlerts), "alerts", alerts.PostableAlerts, "org", alertRule.OrgID)
n, err := sch.multiOrgNotifier.AlertmanagerFor(alertRule.OrgID) n, err := sch.multiOrgNotifier.AlertmanagerFor(alertRule.OrgID)
if err == nil { if err == nil {