mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): rename state response method
This commit is contained in:
parent
403fdebca3
commit
6edae37ac9
@ -121,20 +121,19 @@ func (e *Engine) resultHandler() {
|
|||||||
|
|
||||||
result.State = alertstates.Critical
|
result.State = alertstates.Critical
|
||||||
result.Description = fmt.Sprintf("Failed to run check after %d retires, Error: %v", maxAlertExecutionRetries, result.Error)
|
result.Description = fmt.Sprintf("Failed to run check after %d retires, Error: %v", maxAlertExecutionRetries, result.Error)
|
||||||
e.saveState(result)
|
e.reactToState(result)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.AlertJob.ResetRetry()
|
result.AlertJob.ResetRetry()
|
||||||
e.saveState(result)
|
e.reactToState(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) saveState(result *AlertResult) {
|
func (e *Engine) reactToState(result *AlertResult) {
|
||||||
query := &m.GetAlertByIdQuery{Id: result.AlertJob.Rule.Id}
|
query := &m.GetAlertByIdQuery{Id: result.AlertJob.Rule.Id}
|
||||||
bus.Dispatch(query)
|
bus.Dispatch(query)
|
||||||
|
|
||||||
e.notifier.Notify(result)
|
|
||||||
if query.Result.ShouldUpdateState(result.State) {
|
if query.Result.ShouldUpdateState(result.State) {
|
||||||
cmd := &m.UpdateAlertStateCommand{
|
cmd := &m.UpdateAlertStateCommand{
|
||||||
AlertId: result.AlertJob.Rule.Id,
|
AlertId: result.AlertJob.Rule.Id,
|
||||||
@ -146,9 +145,7 @@ func (e *Engine) saveState(result *AlertResult) {
|
|||||||
e.log.Error("Failed to save state", "error", err)
|
e.log.Error("Failed to save state", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.log.Debug("will notify! about", "new state", result.State)
|
e.log.Debug("will notify about new state", "new state", result.State)
|
||||||
|
e.notifier.Notify(result)
|
||||||
} else {
|
|
||||||
e.log.Debug("state remains the same!")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user