Explorar o código

alertmanager: if there are no alerts to send, do nothing

Corentin Chary %!s(int64=7) %!d(string=hai) anos
pai
achega
777c1024c9
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      pkg/services/alerting/notifiers/alertmanager.go

+ 4 - 0
pkg/services/alerting/notifiers/alertmanager.go

@@ -78,6 +78,10 @@ func (this *AlertmanagerNotifier) Notify(evalContext *alerting.EvalContext) erro
 		alerts = append(alerts, alertJSON)
 		alerts = append(alerts, alertJSON)
 	}
 	}
 
 
+	if len(alerts) == 0 {
+		return nil
+	}
+
 	bodyJSON := simplejson.NewFromAny(alerts)
 	bodyJSON := simplejson.NewFromAny(alerts)
 	body, _ := bodyJSON.MarshalJSON()
 	body, _ := bodyJSON.MarshalJSON()