From 3a7939c930052a678e2aaec4e20b4c5e26b7dc74 Mon Sep 17 00:00:00 2001 From: Thibault Chataigner Date: Thu, 16 Nov 2017 10:26:53 +0100 Subject: [PATCH] Alertmanager notifier: make it match the new notifier interface Signed-off-by: Thibault Chataigner --- pkg/services/alerting/notifiers/alertmanager.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/services/alerting/notifiers/alertmanager.go b/pkg/services/alerting/notifiers/alertmanager.go index 29b2474d8c9..163cb11b45e 100644 --- a/pkg/services/alerting/notifiers/alertmanager.go +++ b/pkg/services/alerting/notifiers/alertmanager.go @@ -45,6 +45,13 @@ type AlertmanagerNotifier struct { log log.Logger } +func (this *AlertmanagerNotifier) ShouldNotify(evalContext *alerting.EvalContext) bool { + if evalContext.Rule.State == m.AlertStateAlerting { + return true + } + return false +} + func (this *AlertmanagerNotifier) Notify(evalContext *alerting.EvalContext) error { this.log.Info("Sending alertmanager") @@ -52,11 +59,8 @@ func (this *AlertmanagerNotifier) Notify(evalContext *alerting.EvalContext) erro for _, match := range evalContext.EvalMatches { alertJSON := simplejson.New() alertJSON.Set("startsAt", evalContext.StartTime.UTC().Format(time.RFC3339)) - if evalContext.Rule.State == m.AlertStateAlerting { - alertJSON.Set("endsAt", "0001-01-01T00:00:00Z") - } else { - alertJSON.Set("endsAt", evalContext.EndTime.UTC().Format(time.RFC3339)) - } + // Rule state should always be alerting if notifying. + alertJSON.Set("endsAt", "0001-01-01T00:00:00Z") ruleUrl, err := evalContext.GetRuleUrl() if err == nil {