Commit 00dddca2 by bergquist

alerting: dedupe alert notifications when running multiple servers

alert notifications will only be sent if the database value
is updated.

ref #6957
parent d5245fd1
......@@ -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()
......
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