mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
alerting: dedupe alert notifications when running multiple servers
alert notifications will only be sent if the database value is updated. ref #6957
This commit is contained in:
parent
d5245fd19a
commit
00dddca26a
@ -35,6 +35,7 @@ const (
|
||||
|
||||
var (
|
||||
ErrCannotChangeStateOnPausedAlert error = fmt.Errorf("Cannot change state on pause alert")
|
||||
ErrRequiresNewState error = fmt.Errorf("update alert state requires a new state.")
|
||||
)
|
||||
|
||||
func (s AlertStateType) IsValid() bool {
|
||||
|
@ -61,6 +61,12 @@ func (handler *DefaultResultHandler) Handle(evalContext *EvalContext) error {
|
||||
handler.log.Error("Cannot change state on alert thats pause", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err == m.ErrRequiresNewState {
|
||||
handler.log.Info("Alert already updated")
|
||||
return nil
|
||||
}
|
||||
|
||||
handler.log.Error("Failed to save state", "error", err)
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,10 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
|
||||
return m.ErrCannotChangeStateOnPausedAlert
|
||||
}
|
||||
|
||||
if alert.State == cmd.State {
|
||||
return m.ErrRequiresNewState
|
||||
}
|
||||
|
||||
alert.State = cmd.State
|
||||
alert.StateChanges += 1
|
||||
alert.NewStateDate = time.Now()
|
||||
|
Loading…
Reference in New Issue
Block a user