mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
fix(alerting): only expose metrics if executing alerts (#85512)
This commit is contained in:
parent
85127464a3
commit
7cfd470c91
@ -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,
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user