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

This commit is contained in:
Sofia Papagiannaki 2019-09-05 18:54:27 +03:00 committed by GitHub
parent 1bd4f51189
commit 388d3d3714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

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

View File

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