Commit 388d3d37 by Sofia Papagiannaki Committed by GitHub

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

parent 1bd4f511
...@@ -71,11 +71,10 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC ...@@ -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 okOrPending := newState == models.AlertStatePending || newState == models.AlertStateOK
// Do not notify when new state is ok/pending when previous is unknown or no_data // Do not notify when new state is ok/pending when previous is unknown
if unknownOrNoData && okOrPending { if prevState == models.AlertStateUnknown && okOrPending {
return false return false
} }
......
...@@ -157,6 +157,13 @@ func TestShouldSendAlertNotification(t *testing.T) { ...@@ -157,6 +157,13 @@ func TestShouldSendAlertNotification(t *testing.T) {
expect: false, expect: false,
}, },
{
name: "no_data -> ok",
prevState: models.AlertStateNoData,
newState: models.AlertStateOK,
expect: true,
},
} }
for _, tc := range tcs { for _, tc := range tcs {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment