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
}
}
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
}
......
......@@ -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 {
......
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