Browse Source

Notification is sent when state changes from no_data to ok (#18920)

Sofia Papagiannaki 6 years ago
parent
commit
388d3d3714

+ 2 - 3
pkg/services/alerting/notifiers/base.go

@@ -71,11 +71,10 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC
 		}
 	}
 
-	unknownOrNoData := prevState == models.AlertStateUnknown || prevState == models.AlertStateNoData
 	okOrPending := newState == models.AlertStatePending || newState == models.AlertStateOK
 
-	// Do not notify when new state is ok/pending when previous is unknown or no_data
-	if unknownOrNoData && okOrPending {
+	// Do not notify when new state is ok/pending when previous is unknown
+	if prevState == models.AlertStateUnknown && okOrPending {
 		return false
 	}
 

+ 7 - 0
pkg/services/alerting/notifiers/base_test.go

@@ -157,6 +157,13 @@ func TestShouldSendAlertNotification(t *testing.T) {
 
 			expect: false,
 		},
+		{
+			name:      "no_data -> ok",
+			prevState: models.AlertStateNoData,
+			newState:  models.AlertStateOK,
+
+			expect: true,
+		},
 	}
 
 	for _, tc := range tcs {