mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
Notification is sent when state changes from no_data to ok (#18920)
This commit is contained in:
parent
1bd4f51189
commit
388d3d3714
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user