Alerting: Add rule_query_offset setting for Prometheus rule conversion (#102500)

Adds a new configuration option to specify a time offset for rule evaluation, which gets applied and saved during the Prometheus -> Grafana conversion. For example:

[unified_alerting.prometheus_conversion]
rule_query_offset = 1m

Changing this option affects only the rules imported after the change. If query_offset is set at the group level, it takes precedence over this setting.

Default is set to 1m.
This commit is contained in:
Alexander Akhmetov
2025-03-20 15:31:21 +01:00
committed by GitHub
parent 41a2aa41f8
commit 756b45402c
5 changed files with 66 additions and 2 deletions
@@ -463,6 +463,7 @@ func (srv *ConvertPrometheusSrv) convertToGrafanaRuleGroup(
IsPaused: pauseAlertRules,
},
KeepOriginalRuleDefinition: util.Pointer(keepOriginalRuleDefinition),
EvaluationOffset: &srv.cfg.PrometheusConversion.RuleQueryOffset,
},
)
if err != nil {