mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
add config sanity checks for prometheus_agent
This commit is contained in:
committed by
Dan Christian Bogos
parent
347ea9d988
commit
ea3ebcc6dd
@@ -1094,6 +1094,9 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> the CleanupInterval needs to be bigger than 0", utils.AnalyzerS)
|
||||
}
|
||||
}
|
||||
if err := cfg.prometheusAgentCfg.validate(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -113,6 +115,27 @@ func (c PrometheusAgentCfg) Clone() *PrometheusAgentCfg {
|
||||
}
|
||||
}
|
||||
|
||||
func (c PrometheusAgentCfg) validate(cfg *CGRConfig) error {
|
||||
if !c.Enabled {
|
||||
return nil
|
||||
}
|
||||
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)
|
||||
}
|
||||
if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) {
|
||||
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.PrometheusAgent, connID)
|
||||
}
|
||||
}
|
||||
if len(c.CoreSConns) > 0 {
|
||||
if c.CollectGoMetrics || c.CollectProcessMetrics {
|
||||
return fmt.Errorf("<%s> collect_go_metrics and collect_process_metrics cannot be enabled when using CoreSConns",
|
||||
utils.PrometheusAgent)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func diffPrometheusAgentJsonCfg(d *PrometheusAgentJsonCfg, v1, v2 *PrometheusAgentCfg) *PrometheusAgentJsonCfg {
|
||||
if d == nil {
|
||||
d = new(PrometheusAgentJsonCfg)
|
||||
|
||||
Reference in New Issue
Block a user