From 331b7427e448e211d30803bef9065d95b7fd8c44 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 18 Sep 2025 09:35:24 +0300 Subject: [PATCH] config: add sanity check for undefined prometheus conns previously existed only for StatSConns, added also for CoreSConns and CacheSConns --- config/prometheus.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/prometheus.go b/config/prometheus.go index c1de347c5..b3ed7ea15 100644 --- a/config/prometheus.go +++ b/config/prometheus.go @@ -133,6 +133,16 @@ func (c PrometheusAgentCfg) validate(cfg *CGRConfig) error { if !c.Enabled { return nil } + for _, connID := range cfg.prometheusAgentCfg.CacheSConns { + if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { + return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.PrometheusAgent, connID) + } + } + for _, connID := range cfg.prometheusAgentCfg.CoreSConns { + if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { + return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.PrometheusAgent, connID) + } + } for _, connID := range c.StatSConns { if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.statsCfg.Enabled { return fmt.Errorf("<%s> not enabled but requested by <%s> component", utils.StatService, utils.PrometheusAgent)