mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Limit and clean up old alert rules versions (#89754)
This commit is contained in:
@@ -121,6 +121,11 @@ type UnifiedAlertingSettings struct {
|
||||
|
||||
// Duration for which a resolved alert state transition will continue to be sent to the Alertmanager.
|
||||
ResolvedAlertRetention time.Duration
|
||||
|
||||
// RuleVersionRecordLimit defines the limit of how many alert rule versions
|
||||
// should be stored in the database for each alert_rule in an organization including the current one.
|
||||
// 0 value means no limit
|
||||
RuleVersionRecordLimit int
|
||||
}
|
||||
|
||||
type RecordingRuleSettings struct {
|
||||
@@ -455,6 +460,11 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
|
||||
return err
|
||||
}
|
||||
|
||||
uaCfg.RuleVersionRecordLimit = ua.Key("rule_version_record_limit").MustInt(0)
|
||||
if uaCfg.RuleVersionRecordLimit < 0 {
|
||||
return fmt.Errorf("setting 'rule_version_record_limit' is invalid, only 0 or a positive integer are allowed")
|
||||
}
|
||||
|
||||
cfg.UnifiedAlerting = uaCfg
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user