mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Allow pausing alerts from provisioning (#62263)
* Allow pausing alerts from provisioning * Update swagger * Add IsPaused to provision export endpoints * Add pause field in sample.yml * Add exception for reset state in first loop iteration of scheduler if rule is paused * Update provision definition and swagger docs * Fix provisioning export tests * Suggestion: Simplify if condition * Add more context to a comment
This commit is contained in:
@@ -474,7 +474,11 @@ func (sch *schedule) ruleRoutine(grafanaCtx context.Context, key ngmodels.AlertR
|
||||
isPaused := ctx.rule.IsPaused
|
||||
// fetch latest alert rule version
|
||||
if currentRuleVersion != newVersion {
|
||||
if currentRuleVersion > 0 { // do not clean up state if the eval loop has just started.
|
||||
// Do not clean up state if the eval loop has just started.
|
||||
// We need to reset state if the loop has started and the alert is already paused. It can happen,
|
||||
// if we have an alert with state and we do file provision with stateful Grafana, that state
|
||||
// lingers in DB and won't be cleaned up until next alert rule update.
|
||||
if currentRuleVersion > 0 || isPaused {
|
||||
logger.Debug("Got a new version of alert rule. Clear up the state and refresh extra labels", "version", currentRuleVersion, "newVersion", newVersion)
|
||||
resetState(grafanaCtx, isPaused)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user