fix(alerting): only expose metrics if executing alerts (#85512)

This commit is contained in:
Jean-Philippe Quéméner
2024-04-03 17:18:02 +02:00
committed by GitHub
parent 85127464a3
commit 7cfd470c91
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -279,6 +279,7 @@ func (ng *AlertNG) init() error {
cfg := state.ManagerCfg{
Metrics: ng.Metrics.GetStateMetrics(),
ExternalURL: appUrl,
DisableExecution: !ng.Cfg.UnifiedAlerting.ExecuteAlerts,
InstanceStore: ng.store,
Images: ng.ImageService,
Clock: clk,
+4 -1
View File
@@ -71,6 +71,8 @@ type ManagerCfg struct {
ApplyNoDataAndErrorToAllStates bool
RulesPerRuleGroupLimit int64
DisableExecution bool
Tracer tracing.Tracer
Log log.Logger
}
@@ -78,7 +80,8 @@ type ManagerCfg struct {
func NewManager(cfg ManagerCfg, statePersister StatePersister) *Manager {
// Metrics for the cache use a collector, so they need access to the register directly.
c := newCache()
if cfg.Metrics != nil {
// Only expose the metrics if this grafana server does execute alerts.
if cfg.Metrics != nil && !cfg.DisableExecution {
c.RegisterMetrics(cfg.Metrics.Registerer())
}