mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
implement config object for prometheus_agent
This commit is contained in:
committed by
Dan Christian Bogos
parent
19f39945d9
commit
531a752078
391
config/config.go
391
config/config.go
@@ -150,6 +150,7 @@ func newCGRConfig(config []byte) (cfg *CGRConfig, err error) {
|
||||
cfg.diameterAgentCfg = new(DiameterAgentCfg)
|
||||
cfg.radiusAgentCfg = new(RadiusAgentCfg)
|
||||
cfg.dnsAgentCfg = new(DNSAgentCfg)
|
||||
cfg.prometheusAgentCfg = new(PrometheusAgentCfg)
|
||||
cfg.attributeSCfg = &AttributeSCfg{Opts: &AttributesOpts{}}
|
||||
cfg.chargerSCfg = new(ChargerSCfg)
|
||||
cfg.resourceSCfg = &ResourceSConfig{Opts: &ResourcesOpts{}}
|
||||
@@ -293,48 +294,49 @@ type CGRConfig struct {
|
||||
|
||||
templates FcTemplates
|
||||
|
||||
generalCfg *GeneralCfg // General config
|
||||
dataDbCfg *DataDbCfg // Database config
|
||||
storDbCfg *StorDbCfg // StroreDb config
|
||||
tlsCfg *TLSCfg // TLS config
|
||||
cacheCfg *CacheCfg // Cache config
|
||||
listenCfg *ListenCfg // Listen config
|
||||
httpCfg *HTTPCfg // HTTP config
|
||||
filterSCfg *FilterSCfg // FilterS config
|
||||
ralsCfg *RalsCfg // Rals config
|
||||
schedulerCfg *SchedulerCfg // Scheduler config
|
||||
cdrsCfg *CdrsCfg // Cdrs config
|
||||
sessionSCfg *SessionSCfg // SessionS config
|
||||
fsAgentCfg *FsAgentCfg // FreeSWITCHAgent config
|
||||
kamAgentCfg *KamAgentCfg // KamailioAgent config
|
||||
asteriskAgentCfg *AsteriskAgentCfg // AsteriskAgent config
|
||||
diameterAgentCfg *DiameterAgentCfg // DiameterAgent config
|
||||
radiusAgentCfg *RadiusAgentCfg // RadiusAgent config
|
||||
dnsAgentCfg *DNSAgentCfg // DNSAgent config
|
||||
attributeSCfg *AttributeSCfg // AttributeS config
|
||||
chargerSCfg *ChargerSCfg // ChargerS config
|
||||
resourceSCfg *ResourceSConfig // ResourceS config
|
||||
statsCfg *StatSCfg // StatS config
|
||||
trendsCfg *TrendSCfg // TrendS config
|
||||
rankingsCfg *RankingSCfg // Rankings config
|
||||
thresholdSCfg *ThresholdSCfg // ThresholdS config
|
||||
routeSCfg *RouteSCfg // RouteS config
|
||||
sureTaxCfg *SureTaxCfg // SureTax config
|
||||
dispatcherSCfg *DispatcherSCfg // DispatcherS config
|
||||
registrarCCfg *RegistrarCCfgs // RegistrarC config
|
||||
loaderCgrCfg *LoaderCgrCfg // LoaderCgr config
|
||||
migratorCgrCfg *MigratorCgrCfg // MigratorCgr config
|
||||
mailerCfg *MailerCfg // Mailer config
|
||||
analyzerSCfg *AnalyzerSCfg // AnalyzerS config
|
||||
apier *ApierCfg // APIer config
|
||||
ersCfg *ERsCfg // EventReader config
|
||||
eesCfg *EEsCfg // EventExporter config
|
||||
sipAgentCfg *SIPAgentCfg // SIPAgent config
|
||||
janusAgentCfg *JanusAgentCfg // JanusAgent config
|
||||
configSCfg *ConfigSCfg // ConfigS config
|
||||
apiBanCfg *APIBanCfg // APIBan config
|
||||
sentryPeerCfg *SentryPeerCfg //SentryPeer config
|
||||
coreSCfg *CoreSCfg // CoreS config
|
||||
generalCfg *GeneralCfg // General config
|
||||
dataDbCfg *DataDbCfg // Database config
|
||||
storDbCfg *StorDbCfg // StroreDb config
|
||||
tlsCfg *TLSCfg // TLS config
|
||||
cacheCfg *CacheCfg // Cache config
|
||||
listenCfg *ListenCfg // Listen config
|
||||
httpCfg *HTTPCfg // HTTP config
|
||||
filterSCfg *FilterSCfg // FilterS config
|
||||
ralsCfg *RalsCfg // Rals config
|
||||
schedulerCfg *SchedulerCfg // Scheduler config
|
||||
cdrsCfg *CdrsCfg // Cdrs config
|
||||
sessionSCfg *SessionSCfg // SessionS config
|
||||
fsAgentCfg *FsAgentCfg // FreeSWITCHAgent config
|
||||
kamAgentCfg *KamAgentCfg // KamailioAgent config
|
||||
asteriskAgentCfg *AsteriskAgentCfg // AsteriskAgent config
|
||||
diameterAgentCfg *DiameterAgentCfg // DiameterAgent config
|
||||
radiusAgentCfg *RadiusAgentCfg // RadiusAgent config
|
||||
dnsAgentCfg *DNSAgentCfg // DNSAgent config
|
||||
prometheusAgentCfg *PrometheusAgentCfg // PrometheusAgent config
|
||||
attributeSCfg *AttributeSCfg // AttributeS config
|
||||
chargerSCfg *ChargerSCfg // ChargerS config
|
||||
resourceSCfg *ResourceSConfig // ResourceS config
|
||||
statsCfg *StatSCfg // StatS config
|
||||
trendsCfg *TrendSCfg // TrendS config
|
||||
rankingsCfg *RankingSCfg // Rankings config
|
||||
thresholdSCfg *ThresholdSCfg // ThresholdS config
|
||||
routeSCfg *RouteSCfg // RouteS config
|
||||
sureTaxCfg *SureTaxCfg // SureTax config
|
||||
dispatcherSCfg *DispatcherSCfg // DispatcherS config
|
||||
registrarCCfg *RegistrarCCfgs // RegistrarC config
|
||||
loaderCgrCfg *LoaderCgrCfg // LoaderCgr config
|
||||
migratorCgrCfg *MigratorCgrCfg // MigratorCgr config
|
||||
mailerCfg *MailerCfg // Mailer config
|
||||
analyzerSCfg *AnalyzerSCfg // AnalyzerS config
|
||||
apier *ApierCfg // APIer config
|
||||
ersCfg *ERsCfg // EventReader config
|
||||
eesCfg *EEsCfg // EventExporter config
|
||||
sipAgentCfg *SIPAgentCfg // SIPAgent config
|
||||
janusAgentCfg *JanusAgentCfg // JanusAgent config
|
||||
configSCfg *ConfigSCfg // ConfigS config
|
||||
apiBanCfg *APIBanCfg // APIBan config
|
||||
sentryPeerCfg *SentryPeerCfg //SentryPeer config
|
||||
coreSCfg *CoreSCfg // CoreS config
|
||||
|
||||
cacheDP map[string]utils.MapStorage
|
||||
cacheDPMux sync.RWMutex
|
||||
@@ -366,7 +368,7 @@ func (cfg *CGRConfig) loadFromJSONCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
cfg.loadCdrsCfg, cfg.loadSessionSCfg,
|
||||
cfg.loadFreeswitchAgentCfg, cfg.loadKamAgentCfg,
|
||||
cfg.loadAsteriskAgentCfg, cfg.loadDiameterAgentCfg, cfg.loadRadiusAgentCfg,
|
||||
cfg.loadDNSAgentCfg, cfg.loadHTTPAgentCfg, cfg.loadAttributeSCfg,
|
||||
cfg.loadDNSAgentCfg, cfg.loadHTTPAgentCfg, cfg.loadPrometheusAgentCfg, cfg.loadAttributeSCfg,
|
||||
cfg.loadChargerSCfg, cfg.loadResourceSCfg, cfg.loadStatSCfg, cfg.loadTrendSCfg,
|
||||
cfg.loadRankingSCfg, cfg.loadThresholdSCfg, cfg.loadRouteSCfg, cfg.loadLoaderSCfg,
|
||||
cfg.loadMailerCfg, cfg.loadSureTaxCfg, cfg.loadDispatcherSCfg,
|
||||
@@ -601,6 +603,15 @@ func (cfg *CGRConfig) loadHTTPAgentCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
return cfg.httpAgentCfg.loadFromJSONCfg(jsnHTTPAgntCfg, cfg.generalCfg.RSRSep)
|
||||
}
|
||||
|
||||
// loadPrometheusAgentCfg loads the PrometheusAgent section of the configuration.
|
||||
func (cfg *CGRConfig) loadPrometheusAgentCfg(jsnCfg *CgrJsonCfg) error {
|
||||
jsnPACfg, err := jsnCfg.PrometheusAgentJsonCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cfg.prometheusAgentCfg.loadFromJSONCfg(jsnPACfg)
|
||||
}
|
||||
|
||||
// loadAttributeSCfg loads the AttributeS section of the configuration
|
||||
func (cfg *CGRConfig) loadAttributeSCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
var jsnAttributeSCfg *AttributeSJsonCfg
|
||||
@@ -881,6 +892,13 @@ func (cfg *CGRConfig) DNSAgentCfg() *DNSAgentCfg {
|
||||
return cfg.dnsAgentCfg
|
||||
}
|
||||
|
||||
// PrometheusAgentCfg returns the config for Prometheus Agent
|
||||
func (cfg *CGRConfig) PrometheusAgentCfg() *PrometheusAgentCfg {
|
||||
cfg.lks[PrometheusAgentJSON].Lock()
|
||||
defer cfg.lks[PrometheusAgentJSON].Unlock()
|
||||
return cfg.prometheusAgentCfg
|
||||
}
|
||||
|
||||
// AttributeSCfg returns the config for AttributeS
|
||||
func (cfg *CGRConfig) AttributeSCfg() *AttributeSCfg {
|
||||
cfg.lks[ATTRIBUTE_JSN].Lock()
|
||||
@@ -1241,52 +1259,53 @@ func (cfg *CGRConfig) UnlockSections(lkIDs ...string) {
|
||||
|
||||
func (cfg *CGRConfig) getLoadFunctions() map[string]func(*CgrJsonCfg) error {
|
||||
return map[string]func(*CgrJsonCfg) error{
|
||||
GENERAL_JSN: cfg.loadGeneralCfg,
|
||||
DATADB_JSN: cfg.loadDataDBCfg,
|
||||
STORDB_JSN: cfg.loadStorDBCfg,
|
||||
LISTEN_JSN: cfg.loadListenCfg,
|
||||
TlsCfgJson: cfg.loadTLSCgrCfg,
|
||||
HTTP_JSN: cfg.loadHTTPCfg,
|
||||
SCHEDULER_JSN: cfg.loadSchedulerCfg,
|
||||
CACHE_JSN: cfg.loadCacheCfg,
|
||||
FilterSjsn: cfg.loadFilterSCfg,
|
||||
RALS_JSN: cfg.loadRalSCfg,
|
||||
CDRS_JSN: cfg.loadCdrsCfg,
|
||||
ERsJson: cfg.loadErsCfg,
|
||||
EEsJson: cfg.loadEesCfg,
|
||||
SessionSJson: cfg.loadSessionSCfg,
|
||||
AsteriskAgentJSN: cfg.loadAsteriskAgentCfg,
|
||||
FreeSWITCHAgentJSN: cfg.loadFreeswitchAgentCfg,
|
||||
KamailioAgentJSN: cfg.loadKamAgentCfg,
|
||||
DA_JSN: cfg.loadDiameterAgentCfg,
|
||||
RA_JSN: cfg.loadRadiusAgentCfg,
|
||||
HttpAgentJson: cfg.loadHTTPAgentCfg,
|
||||
DNSAgentJson: cfg.loadDNSAgentCfg,
|
||||
ATTRIBUTE_JSN: cfg.loadAttributeSCfg,
|
||||
ChargerSCfgJson: cfg.loadChargerSCfg,
|
||||
RESOURCES_JSON: cfg.loadResourceSCfg,
|
||||
STATS_JSON: cfg.loadStatSCfg,
|
||||
TRENDS_JSON: cfg.loadTrendSCfg,
|
||||
RANKINGS_JSON: cfg.loadRankingSCfg,
|
||||
THRESHOLDS_JSON: cfg.loadThresholdSCfg,
|
||||
RouteSJson: cfg.loadRouteSCfg,
|
||||
LoaderJson: cfg.loadLoaderSCfg,
|
||||
MAILER_JSN: cfg.loadMailerCfg,
|
||||
SURETAX_JSON: cfg.loadSureTaxCfg,
|
||||
CgrLoaderCfgJson: cfg.loadLoaderCgrCfg,
|
||||
CgrMigratorCfgJson: cfg.loadMigratorCgrCfg,
|
||||
DispatcherSJson: cfg.loadDispatcherSCfg,
|
||||
RegistrarCJson: cfg.loadRegistrarCCfg,
|
||||
AnalyzerCfgJson: cfg.loadAnalyzerCgrCfg,
|
||||
ApierS: cfg.loadApierCfg,
|
||||
RPCConnsJsonName: cfg.loadRPCConns,
|
||||
SIPAgentJson: cfg.loadSIPAgentCfg,
|
||||
JanusAgentJson: cfg.loadJanusAgentCfg,
|
||||
TemplatesJson: cfg.loadTemplateSCfg,
|
||||
ConfigSJson: cfg.loadConfigSCfg,
|
||||
APIBanCfgJson: cfg.loadAPIBanCgrCfg,
|
||||
SentryPeerCfgJson: cfg.loadSentryPeerCgrCfg,
|
||||
CoreSCfgJson: cfg.loadCoreSCfg,
|
||||
GENERAL_JSN: cfg.loadGeneralCfg,
|
||||
DATADB_JSN: cfg.loadDataDBCfg,
|
||||
STORDB_JSN: cfg.loadStorDBCfg,
|
||||
LISTEN_JSN: cfg.loadListenCfg,
|
||||
TlsCfgJson: cfg.loadTLSCgrCfg,
|
||||
HTTP_JSN: cfg.loadHTTPCfg,
|
||||
SCHEDULER_JSN: cfg.loadSchedulerCfg,
|
||||
CACHE_JSN: cfg.loadCacheCfg,
|
||||
FilterSjsn: cfg.loadFilterSCfg,
|
||||
RALS_JSN: cfg.loadRalSCfg,
|
||||
CDRS_JSN: cfg.loadCdrsCfg,
|
||||
ERsJson: cfg.loadErsCfg,
|
||||
EEsJson: cfg.loadEesCfg,
|
||||
SessionSJson: cfg.loadSessionSCfg,
|
||||
AsteriskAgentJSN: cfg.loadAsteriskAgentCfg,
|
||||
FreeSWITCHAgentJSN: cfg.loadFreeswitchAgentCfg,
|
||||
KamailioAgentJSN: cfg.loadKamAgentCfg,
|
||||
DA_JSN: cfg.loadDiameterAgentCfg,
|
||||
RA_JSN: cfg.loadRadiusAgentCfg,
|
||||
HttpAgentJson: cfg.loadHTTPAgentCfg,
|
||||
DNSAgentJson: cfg.loadDNSAgentCfg,
|
||||
PrometheusAgentJSON: cfg.loadPrometheusAgentCfg,
|
||||
ATTRIBUTE_JSN: cfg.loadAttributeSCfg,
|
||||
ChargerSCfgJson: cfg.loadChargerSCfg,
|
||||
RESOURCES_JSON: cfg.loadResourceSCfg,
|
||||
STATS_JSON: cfg.loadStatSCfg,
|
||||
TRENDS_JSON: cfg.loadTrendSCfg,
|
||||
RANKINGS_JSON: cfg.loadRankingSCfg,
|
||||
THRESHOLDS_JSON: cfg.loadThresholdSCfg,
|
||||
RouteSJson: cfg.loadRouteSCfg,
|
||||
LoaderJson: cfg.loadLoaderSCfg,
|
||||
MAILER_JSN: cfg.loadMailerCfg,
|
||||
SURETAX_JSON: cfg.loadSureTaxCfg,
|
||||
CgrLoaderCfgJson: cfg.loadLoaderCgrCfg,
|
||||
CgrMigratorCfgJson: cfg.loadMigratorCgrCfg,
|
||||
DispatcherSJson: cfg.loadDispatcherSCfg,
|
||||
RegistrarCJson: cfg.loadRegistrarCCfg,
|
||||
AnalyzerCfgJson: cfg.loadAnalyzerCgrCfg,
|
||||
ApierS: cfg.loadApierCfg,
|
||||
RPCConnsJsonName: cfg.loadRPCConns,
|
||||
SIPAgentJson: cfg.loadSIPAgentCfg,
|
||||
JanusAgentJson: cfg.loadJanusAgentCfg,
|
||||
TemplatesJson: cfg.loadTemplateSCfg,
|
||||
ConfigSJson: cfg.loadConfigSCfg,
|
||||
APIBanCfgJson: cfg.loadAPIBanCgrCfg,
|
||||
SentryPeerCfgJson: cfg.loadSentryPeerCgrCfg,
|
||||
CoreSCfgJson: cfg.loadCoreSCfg,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1510,6 +1529,8 @@ func (cfg *CGRConfig) reloadSections(sections ...string) {
|
||||
cfg.rldChans[HttpAgentJson] <- struct{}{}
|
||||
case DNSAgentJson:
|
||||
cfg.rldChans[DNSAgentJson] <- struct{}{}
|
||||
case PrometheusAgentJSON:
|
||||
cfg.rldChans[PrometheusAgentJSON] <- struct{}{}
|
||||
case ATTRIBUTE_JSN:
|
||||
cfg.rldChans[ATTRIBUTE_JSN] <- struct{}{}
|
||||
case ChargerSCfgJson:
|
||||
@@ -1549,51 +1570,52 @@ func (cfg *CGRConfig) reloadSections(sections ...string) {
|
||||
// AsMapInterface returns the config as a map[string]any
|
||||
func (cfg *CGRConfig) AsMapInterface(separator string) (mp map[string]any) {
|
||||
return map[string]any{
|
||||
LoaderJson: cfg.loaderCfg.AsMapInterface(separator),
|
||||
HttpAgentJson: cfg.httpAgentCfg.AsMapInterface(separator),
|
||||
RPCConnsJsonName: cfg.rpcConns.AsMapInterface(),
|
||||
GENERAL_JSN: cfg.generalCfg.AsMapInterface(),
|
||||
DATADB_JSN: cfg.dataDbCfg.AsMapInterface(),
|
||||
STORDB_JSN: cfg.storDbCfg.AsMapInterface(),
|
||||
TlsCfgJson: cfg.tlsCfg.AsMapInterface(),
|
||||
CACHE_JSN: cfg.cacheCfg.AsMapInterface(),
|
||||
LISTEN_JSN: cfg.listenCfg.AsMapInterface(),
|
||||
HTTP_JSN: cfg.httpCfg.AsMapInterface(),
|
||||
FilterSjsn: cfg.filterSCfg.AsMapInterface(),
|
||||
RALS_JSN: cfg.ralsCfg.AsMapInterface(),
|
||||
SCHEDULER_JSN: cfg.schedulerCfg.AsMapInterface(),
|
||||
CDRS_JSN: cfg.cdrsCfg.AsMapInterface(),
|
||||
SessionSJson: cfg.sessionSCfg.AsMapInterface(),
|
||||
FreeSWITCHAgentJSN: cfg.fsAgentCfg.AsMapInterface(separator),
|
||||
KamailioAgentJSN: cfg.kamAgentCfg.AsMapInterface(),
|
||||
AsteriskAgentJSN: cfg.asteriskAgentCfg.AsMapInterface(),
|
||||
DA_JSN: cfg.diameterAgentCfg.AsMapInterface(separator),
|
||||
RA_JSN: cfg.radiusAgentCfg.AsMapInterface(separator),
|
||||
DNSAgentJson: cfg.dnsAgentCfg.AsMapInterface(separator),
|
||||
ATTRIBUTE_JSN: cfg.attributeSCfg.AsMapInterface(),
|
||||
ChargerSCfgJson: cfg.chargerSCfg.AsMapInterface(),
|
||||
RESOURCES_JSON: cfg.resourceSCfg.AsMapInterface(),
|
||||
STATS_JSON: cfg.statsCfg.AsMapInterface(),
|
||||
TRENDS_JSON: cfg.trendsCfg.AsMapInterface(),
|
||||
RANKINGS_JSON: cfg.rankingsCfg.AsMapInterface(),
|
||||
THRESHOLDS_JSON: cfg.thresholdSCfg.AsMapInterface(),
|
||||
RouteSJson: cfg.routeSCfg.AsMapInterface(),
|
||||
SURETAX_JSON: cfg.sureTaxCfg.AsMapInterface(separator),
|
||||
DispatcherSJson: cfg.dispatcherSCfg.AsMapInterface(),
|
||||
RegistrarCJson: cfg.registrarCCfg.AsMapInterface(),
|
||||
CgrLoaderCfgJson: cfg.loaderCgrCfg.AsMapInterface(),
|
||||
CgrMigratorCfgJson: cfg.migratorCgrCfg.AsMapInterface(),
|
||||
MAILER_JSN: cfg.mailerCfg.AsMapInterface(),
|
||||
AnalyzerCfgJson: cfg.analyzerSCfg.AsMapInterface(),
|
||||
ApierS: cfg.apier.AsMapInterface(),
|
||||
ERsJson: cfg.ersCfg.AsMapInterface(separator),
|
||||
APIBanCfgJson: cfg.apiBanCfg.AsMapInterface(),
|
||||
SentryPeerCfgJson: cfg.sentryPeerCfg.AsMapInterface(),
|
||||
EEsJson: cfg.eesCfg.AsMapInterface(separator),
|
||||
SIPAgentJson: cfg.sipAgentCfg.AsMapInterface(separator),
|
||||
TemplatesJson: cfg.templates.AsMapInterface(separator),
|
||||
ConfigSJson: cfg.configSCfg.AsMapInterface(),
|
||||
CoreSCfgJson: cfg.coreSCfg.AsMapInterface(),
|
||||
LoaderJson: cfg.loaderCfg.AsMapInterface(separator),
|
||||
HttpAgentJson: cfg.httpAgentCfg.AsMapInterface(separator),
|
||||
RPCConnsJsonName: cfg.rpcConns.AsMapInterface(),
|
||||
GENERAL_JSN: cfg.generalCfg.AsMapInterface(),
|
||||
DATADB_JSN: cfg.dataDbCfg.AsMapInterface(),
|
||||
STORDB_JSN: cfg.storDbCfg.AsMapInterface(),
|
||||
TlsCfgJson: cfg.tlsCfg.AsMapInterface(),
|
||||
CACHE_JSN: cfg.cacheCfg.AsMapInterface(),
|
||||
LISTEN_JSN: cfg.listenCfg.AsMapInterface(),
|
||||
HTTP_JSN: cfg.httpCfg.AsMapInterface(),
|
||||
FilterSjsn: cfg.filterSCfg.AsMapInterface(),
|
||||
RALS_JSN: cfg.ralsCfg.AsMapInterface(),
|
||||
SCHEDULER_JSN: cfg.schedulerCfg.AsMapInterface(),
|
||||
CDRS_JSN: cfg.cdrsCfg.AsMapInterface(),
|
||||
SessionSJson: cfg.sessionSCfg.AsMapInterface(),
|
||||
FreeSWITCHAgentJSN: cfg.fsAgentCfg.AsMapInterface(separator),
|
||||
KamailioAgentJSN: cfg.kamAgentCfg.AsMapInterface(),
|
||||
AsteriskAgentJSN: cfg.asteriskAgentCfg.AsMapInterface(),
|
||||
DA_JSN: cfg.diameterAgentCfg.AsMapInterface(separator),
|
||||
RA_JSN: cfg.radiusAgentCfg.AsMapInterface(separator),
|
||||
DNSAgentJson: cfg.dnsAgentCfg.AsMapInterface(separator),
|
||||
PrometheusAgentJSON: cfg.prometheusAgentCfg.AsMapInterface(),
|
||||
ATTRIBUTE_JSN: cfg.attributeSCfg.AsMapInterface(),
|
||||
ChargerSCfgJson: cfg.chargerSCfg.AsMapInterface(),
|
||||
RESOURCES_JSON: cfg.resourceSCfg.AsMapInterface(),
|
||||
STATS_JSON: cfg.statsCfg.AsMapInterface(),
|
||||
TRENDS_JSON: cfg.trendsCfg.AsMapInterface(),
|
||||
RANKINGS_JSON: cfg.rankingsCfg.AsMapInterface(),
|
||||
THRESHOLDS_JSON: cfg.thresholdSCfg.AsMapInterface(),
|
||||
RouteSJson: cfg.routeSCfg.AsMapInterface(),
|
||||
SURETAX_JSON: cfg.sureTaxCfg.AsMapInterface(separator),
|
||||
DispatcherSJson: cfg.dispatcherSCfg.AsMapInterface(),
|
||||
RegistrarCJson: cfg.registrarCCfg.AsMapInterface(),
|
||||
CgrLoaderCfgJson: cfg.loaderCgrCfg.AsMapInterface(),
|
||||
CgrMigratorCfgJson: cfg.migratorCgrCfg.AsMapInterface(),
|
||||
MAILER_JSN: cfg.mailerCfg.AsMapInterface(),
|
||||
AnalyzerCfgJson: cfg.analyzerSCfg.AsMapInterface(),
|
||||
ApierS: cfg.apier.AsMapInterface(),
|
||||
ERsJson: cfg.ersCfg.AsMapInterface(separator),
|
||||
APIBanCfgJson: cfg.apiBanCfg.AsMapInterface(),
|
||||
SentryPeerCfgJson: cfg.sentryPeerCfg.AsMapInterface(),
|
||||
EEsJson: cfg.eesCfg.AsMapInterface(separator),
|
||||
SIPAgentJson: cfg.sipAgentCfg.AsMapInterface(separator),
|
||||
TemplatesJson: cfg.templates.AsMapInterface(separator),
|
||||
ConfigSJson: cfg.configSCfg.AsMapInterface(),
|
||||
CoreSCfgJson: cfg.coreSCfg.AsMapInterface(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1706,6 +1728,8 @@ func (cfg *CGRConfig) V1GetConfig(ctx *context.Context, args *SectionWithAPIOpts
|
||||
mp = cfg.RadiusAgentCfg().AsMapInterface(cfg.GeneralCfg().RSRSep)
|
||||
case DNSAgentJson:
|
||||
mp = cfg.DNSAgentCfg().AsMapInterface(cfg.GeneralCfg().RSRSep)
|
||||
case PrometheusAgentJSON:
|
||||
mp = cfg.PrometheusAgentCfg().AsMapInterface()
|
||||
case ATTRIBUTE_JSN:
|
||||
mp = cfg.AttributeSCfg().AsMapInterface()
|
||||
case ChargerSCfgJson:
|
||||
@@ -1878,6 +1902,8 @@ func (cfg *CGRConfig) V1GetConfigAsJSON(ctx *context.Context, args *SectionWithA
|
||||
mp = cfg.DNSAgentCfg().AsMapInterface(cfg.GeneralCfg().RSRSep)
|
||||
case JanusAgentJson:
|
||||
mp = cfg.JanusAgentCfg().AsMapInterface(cfg.GeneralCfg().RSRSep)
|
||||
case PrometheusAgentJSON:
|
||||
mp = cfg.PrometheusAgentCfg().AsMapInterface()
|
||||
case ATTRIBUTE_JSN:
|
||||
mp = cfg.AttributeSCfg().AsMapInterface()
|
||||
case ChargerSCfgJson:
|
||||
@@ -1984,54 +2010,55 @@ func (cfg *CGRConfig) Clone() (cln *CGRConfig) {
|
||||
DataFolderPath: cfg.DataFolderPath,
|
||||
ConfigPath: cfg.ConfigPath,
|
||||
|
||||
dfltEvRdr: cfg.dfltEvRdr.Clone(),
|
||||
dfltEvExp: cfg.dfltEvExp.Clone(),
|
||||
loaderCfg: cfg.loaderCfg.Clone(),
|
||||
httpAgentCfg: cfg.httpAgentCfg.Clone(),
|
||||
rpcConns: cfg.rpcConns.Clone(),
|
||||
templates: cfg.templates.Clone(),
|
||||
generalCfg: cfg.generalCfg.Clone(),
|
||||
dataDbCfg: cfg.dataDbCfg.Clone(),
|
||||
storDbCfg: cfg.storDbCfg.Clone(),
|
||||
tlsCfg: cfg.tlsCfg.Clone(),
|
||||
cacheCfg: cfg.cacheCfg.Clone(),
|
||||
listenCfg: cfg.listenCfg.Clone(),
|
||||
httpCfg: cfg.httpCfg.Clone(),
|
||||
filterSCfg: cfg.filterSCfg.Clone(),
|
||||
ralsCfg: cfg.ralsCfg.Clone(),
|
||||
schedulerCfg: cfg.schedulerCfg.Clone(),
|
||||
cdrsCfg: cfg.cdrsCfg.Clone(),
|
||||
sessionSCfg: cfg.sessionSCfg.Clone(),
|
||||
fsAgentCfg: cfg.fsAgentCfg.Clone(),
|
||||
janusAgentCfg: cfg.janusAgentCfg.Clone(),
|
||||
kamAgentCfg: cfg.kamAgentCfg.Clone(),
|
||||
asteriskAgentCfg: cfg.asteriskAgentCfg.Clone(),
|
||||
diameterAgentCfg: cfg.diameterAgentCfg.Clone(),
|
||||
radiusAgentCfg: cfg.radiusAgentCfg.Clone(),
|
||||
dnsAgentCfg: cfg.dnsAgentCfg.Clone(),
|
||||
attributeSCfg: cfg.attributeSCfg.Clone(),
|
||||
chargerSCfg: cfg.chargerSCfg.Clone(),
|
||||
resourceSCfg: cfg.resourceSCfg.Clone(),
|
||||
statsCfg: cfg.statsCfg.Clone(),
|
||||
trendsCfg: cfg.trendsCfg.Clone(),
|
||||
rankingsCfg: cfg.rankingsCfg.Clone(),
|
||||
thresholdSCfg: cfg.thresholdSCfg.Clone(),
|
||||
routeSCfg: cfg.routeSCfg.Clone(),
|
||||
sureTaxCfg: cfg.sureTaxCfg.Clone(),
|
||||
dispatcherSCfg: cfg.dispatcherSCfg.Clone(),
|
||||
registrarCCfg: cfg.registrarCCfg.Clone(),
|
||||
loaderCgrCfg: cfg.loaderCgrCfg.Clone(),
|
||||
migratorCgrCfg: cfg.migratorCgrCfg.Clone(),
|
||||
mailerCfg: cfg.mailerCfg.Clone(),
|
||||
analyzerSCfg: cfg.analyzerSCfg.Clone(),
|
||||
apier: cfg.apier.Clone(),
|
||||
ersCfg: cfg.ersCfg.Clone(),
|
||||
eesCfg: cfg.eesCfg.Clone(),
|
||||
sipAgentCfg: cfg.sipAgentCfg.Clone(),
|
||||
configSCfg: cfg.configSCfg.Clone(),
|
||||
apiBanCfg: cfg.apiBanCfg.Clone(),
|
||||
sentryPeerCfg: cfg.sentryPeerCfg.Clone(),
|
||||
coreSCfg: cfg.coreSCfg.Clone(),
|
||||
dfltEvRdr: cfg.dfltEvRdr.Clone(),
|
||||
dfltEvExp: cfg.dfltEvExp.Clone(),
|
||||
loaderCfg: cfg.loaderCfg.Clone(),
|
||||
httpAgentCfg: cfg.httpAgentCfg.Clone(),
|
||||
rpcConns: cfg.rpcConns.Clone(),
|
||||
templates: cfg.templates.Clone(),
|
||||
generalCfg: cfg.generalCfg.Clone(),
|
||||
dataDbCfg: cfg.dataDbCfg.Clone(),
|
||||
storDbCfg: cfg.storDbCfg.Clone(),
|
||||
tlsCfg: cfg.tlsCfg.Clone(),
|
||||
cacheCfg: cfg.cacheCfg.Clone(),
|
||||
listenCfg: cfg.listenCfg.Clone(),
|
||||
httpCfg: cfg.httpCfg.Clone(),
|
||||
filterSCfg: cfg.filterSCfg.Clone(),
|
||||
ralsCfg: cfg.ralsCfg.Clone(),
|
||||
schedulerCfg: cfg.schedulerCfg.Clone(),
|
||||
cdrsCfg: cfg.cdrsCfg.Clone(),
|
||||
sessionSCfg: cfg.sessionSCfg.Clone(),
|
||||
fsAgentCfg: cfg.fsAgentCfg.Clone(),
|
||||
janusAgentCfg: cfg.janusAgentCfg.Clone(),
|
||||
kamAgentCfg: cfg.kamAgentCfg.Clone(),
|
||||
asteriskAgentCfg: cfg.asteriskAgentCfg.Clone(),
|
||||
diameterAgentCfg: cfg.diameterAgentCfg.Clone(),
|
||||
radiusAgentCfg: cfg.radiusAgentCfg.Clone(),
|
||||
dnsAgentCfg: cfg.dnsAgentCfg.Clone(),
|
||||
prometheusAgentCfg: cfg.prometheusAgentCfg.Clone(),
|
||||
attributeSCfg: cfg.attributeSCfg.Clone(),
|
||||
chargerSCfg: cfg.chargerSCfg.Clone(),
|
||||
resourceSCfg: cfg.resourceSCfg.Clone(),
|
||||
statsCfg: cfg.statsCfg.Clone(),
|
||||
trendsCfg: cfg.trendsCfg.Clone(),
|
||||
rankingsCfg: cfg.rankingsCfg.Clone(),
|
||||
thresholdSCfg: cfg.thresholdSCfg.Clone(),
|
||||
routeSCfg: cfg.routeSCfg.Clone(),
|
||||
sureTaxCfg: cfg.sureTaxCfg.Clone(),
|
||||
dispatcherSCfg: cfg.dispatcherSCfg.Clone(),
|
||||
registrarCCfg: cfg.registrarCCfg.Clone(),
|
||||
loaderCgrCfg: cfg.loaderCgrCfg.Clone(),
|
||||
migratorCgrCfg: cfg.migratorCgrCfg.Clone(),
|
||||
mailerCfg: cfg.mailerCfg.Clone(),
|
||||
analyzerSCfg: cfg.analyzerSCfg.Clone(),
|
||||
apier: cfg.apier.Clone(),
|
||||
ersCfg: cfg.ersCfg.Clone(),
|
||||
eesCfg: cfg.eesCfg.Clone(),
|
||||
sipAgentCfg: cfg.sipAgentCfg.Clone(),
|
||||
configSCfg: cfg.configSCfg.Clone(),
|
||||
apiBanCfg: cfg.apiBanCfg.Clone(),
|
||||
sentryPeerCfg: cfg.sentryPeerCfg.Clone(),
|
||||
coreSCfg: cfg.coreSCfg.Clone(),
|
||||
|
||||
cacheDP: make(map[string]utils.MapStorage),
|
||||
}
|
||||
|
||||
@@ -805,6 +805,17 @@ const CGRATES_CFG_JSON = `
|
||||
},
|
||||
|
||||
|
||||
"prometheus_agent": {
|
||||
"enabled": false, // enables the prometheus agent: <true|false>
|
||||
"path": "/prometheus", // endpoint for prometheus metrics
|
||||
"collect_go_metrics": false, // include Go runtime metrics (memory, GC, goroutines)
|
||||
"collect_process_metrics": false, // include process metrics (CPU, file descriptors)
|
||||
// "cores_conns": [], // connections to CoreS, empty to disable: <""|*internal|$rpc_conns_id>
|
||||
// "stats_conns": [], // connections to StatS, empty to disable: <""|*internal|$rpc_conns_id>
|
||||
// "stat_queue_ids": [] // StatQueue IDs to collect metrics from <[tenant]:ID>
|
||||
},
|
||||
|
||||
|
||||
"attributes": { // AttributeS config
|
||||
"enabled": false, // starts attribute service: <true|false>
|
||||
"stats_conns": [], // connections to StatS, empty to disable: <""|*internal|$rpc_conns_id>
|
||||
|
||||
@@ -23,58 +23,59 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
GENERAL_JSN = "general"
|
||||
CACHE_JSN = "caches"
|
||||
LISTEN_JSN = "listen"
|
||||
HTTP_JSN = "http"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
FilterSjsn = "filters"
|
||||
RALS_JSN = "rals"
|
||||
SCHEDULER_JSN = "schedulers"
|
||||
CDRS_JSN = "cdrs"
|
||||
SessionSJson = "sessions"
|
||||
FreeSWITCHAgentJSN = "freeswitch_agent"
|
||||
KamailioAgentJSN = "kamailio_agent"
|
||||
AsteriskAgentJSN = "asterisk_agent"
|
||||
DA_JSN = "diameter_agent"
|
||||
RA_JSN = "radius_agent"
|
||||
HttpAgentJson = "http_agent"
|
||||
ATTRIBUTE_JSN = "attributes"
|
||||
RESOURCES_JSON = "resources"
|
||||
STATS_JSON = "stats"
|
||||
THRESHOLDS_JSON = "thresholds"
|
||||
TRENDS_JSON = "trends"
|
||||
RANKINGS_JSON = "rankings"
|
||||
RouteSJson = "routes"
|
||||
LoaderJson = "loaders"
|
||||
MAILER_JSN = "mailer"
|
||||
SURETAX_JSON = "suretax"
|
||||
DispatcherSJson = "dispatchers"
|
||||
RegistrarCJson = "registrarc"
|
||||
CgrLoaderCfgJson = "loader"
|
||||
CgrMigratorCfgJson = "migrator"
|
||||
ChargerSCfgJson = "chargers"
|
||||
TlsCfgJson = "tls"
|
||||
AnalyzerCfgJson = "analyzers"
|
||||
ApierS = "apiers"
|
||||
DNSAgentJson = "dns_agent"
|
||||
ERsJson = "ers"
|
||||
EEsJson = "ees"
|
||||
RPCConnsJsonName = "rpc_conns"
|
||||
SIPAgentJson = "sip_agent"
|
||||
JanusAgentJson = "janus_agent"
|
||||
TemplatesJson = "templates"
|
||||
ConfigSJson = "configs"
|
||||
APIBanCfgJson = "apiban"
|
||||
SentryPeerCfgJson = "sentrypeer"
|
||||
CoreSCfgJson = "cores"
|
||||
GENERAL_JSN = "general"
|
||||
CACHE_JSN = "caches"
|
||||
LISTEN_JSN = "listen"
|
||||
HTTP_JSN = "http"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
FilterSjsn = "filters"
|
||||
RALS_JSN = "rals"
|
||||
SCHEDULER_JSN = "schedulers"
|
||||
CDRS_JSN = "cdrs"
|
||||
SessionSJson = "sessions"
|
||||
FreeSWITCHAgentJSN = "freeswitch_agent"
|
||||
KamailioAgentJSN = "kamailio_agent"
|
||||
AsteriskAgentJSN = "asterisk_agent"
|
||||
DA_JSN = "diameter_agent"
|
||||
RA_JSN = "radius_agent"
|
||||
HttpAgentJson = "http_agent"
|
||||
PrometheusAgentJSON = "prometheus_agent"
|
||||
ATTRIBUTE_JSN = "attributes"
|
||||
RESOURCES_JSON = "resources"
|
||||
STATS_JSON = "stats"
|
||||
THRESHOLDS_JSON = "thresholds"
|
||||
TRENDS_JSON = "trends"
|
||||
RANKINGS_JSON = "rankings"
|
||||
RouteSJson = "routes"
|
||||
LoaderJson = "loaders"
|
||||
MAILER_JSN = "mailer"
|
||||
SURETAX_JSON = "suretax"
|
||||
DispatcherSJson = "dispatchers"
|
||||
RegistrarCJson = "registrarc"
|
||||
CgrLoaderCfgJson = "loader"
|
||||
CgrMigratorCfgJson = "migrator"
|
||||
ChargerSCfgJson = "chargers"
|
||||
TlsCfgJson = "tls"
|
||||
AnalyzerCfgJson = "analyzers"
|
||||
ApierS = "apiers"
|
||||
DNSAgentJson = "dns_agent"
|
||||
ERsJson = "ers"
|
||||
EEsJson = "ees"
|
||||
RPCConnsJsonName = "rpc_conns"
|
||||
SIPAgentJson = "sip_agent"
|
||||
JanusAgentJson = "janus_agent"
|
||||
TemplatesJson = "templates"
|
||||
ConfigSJson = "configs"
|
||||
APIBanCfgJson = "apiban"
|
||||
SentryPeerCfgJson = "sentrypeer"
|
||||
CoreSCfgJson = "cores"
|
||||
)
|
||||
|
||||
var (
|
||||
sortedCfgSections = []string{GENERAL_JSN, RPCConnsJsonName, DATADB_JSN, STORDB_JSN, LISTEN_JSN, TlsCfgJson, HTTP_JSN, SCHEDULER_JSN,
|
||||
CACHE_JSN, FilterSjsn, RALS_JSN, CDRS_JSN, ERsJson, SessionSJson, AsteriskAgentJSN, FreeSWITCHAgentJSN, KamailioAgentJSN,
|
||||
DA_JSN, RA_JSN, HttpAgentJson, DNSAgentJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, TRENDS_JSON, RANKINGS_JSON,
|
||||
DA_JSN, RA_JSN, HttpAgentJson, DNSAgentJson, PrometheusAgentJSON, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, TRENDS_JSON, RANKINGS_JSON,
|
||||
THRESHOLDS_JSON, RouteSJson, LoaderJson, MAILER_JSN, SURETAX_JSON, CgrLoaderCfgJson, CgrMigratorCfgJson, DispatcherSJson, JanusAgentJson,
|
||||
AnalyzerCfgJson, ApierS, EEsJson, SIPAgentJson, RegistrarCJson, TemplatesJson, ConfigSJson, APIBanCfgJson, SentryPeerCfgJson, CoreSCfgJson}
|
||||
)
|
||||
@@ -323,6 +324,18 @@ func (jsnCfg CgrJsonCfg) DNSAgentJsonCfg() (da *DNSAgentJsonCfg, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (jc CgrJsonCfg) PrometheusAgentJsonCfg() (*PrometheusAgentJsonCfg, error) {
|
||||
rawCfg, hasKey := jc[PrometheusAgentJSON]
|
||||
if !hasKey {
|
||||
return nil, nil
|
||||
}
|
||||
var pa *PrometheusAgentJsonCfg
|
||||
if err := json.Unmarshal(*rawCfg, &pa); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pa, nil
|
||||
}
|
||||
|
||||
func (cgrJsn CgrJsonCfg) AttributeServJsonCfg() (*AttributeSJsonCfg, error) {
|
||||
rawCfg, hasKey := cgrJsn[ATTRIBUTE_JSN]
|
||||
if !hasKey {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1226,6 +1226,22 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> the CleanupInterval needs to be bigger than 0", utils.AnalyzerS)
|
||||
}
|
||||
}
|
||||
if cfg.prometheusAgentCfg.Enabled {
|
||||
for _, connID := range cfg.prometheusAgentCfg.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(cfg.prometheusAgentCfg.CoreSConns) > 0 {
|
||||
if cfg.prometheusAgentCfg.CollectGoMetrics || cfg.prometheusAgentCfg.CollectProcessMetrics {
|
||||
return fmt.Errorf("<%s> collect_go_metrics and collect_process_metrics cannot be enabled when using CoreSConns",
|
||||
utils.PrometheusAgent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// General config section
|
||||
@@ -960,3 +963,32 @@ type CoreSJsonCfg struct {
|
||||
Caps_stats_interval *string
|
||||
Shutdown_timeout *string
|
||||
}
|
||||
|
||||
// tagInternalConns adds subsystem to internal connections.
|
||||
func tagInternalConns(conns []string, subsystem string) []string {
|
||||
suffix := utils.ConcatenatedKeySep + subsystem
|
||||
result := make([]string, len(conns))
|
||||
for i, conn := range conns {
|
||||
result[i] = conn
|
||||
if conn == utils.MetaInternal {
|
||||
result[i] += suffix
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// stripInternalConns resets all internal connection variants to base type (by
|
||||
// removing the subsystem suffix).
|
||||
func stripInternalConns(conns []string) []string {
|
||||
if conns == nil {
|
||||
return nil
|
||||
}
|
||||
result := make([]string, len(conns))
|
||||
for i, conn := range conns {
|
||||
result[i] = conn
|
||||
if strings.HasPrefix(conn, utils.MetaInternal) {
|
||||
result[i] = utils.MetaInternal
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
108
config/prometheus.go
Normal file
108
config/prometheus.go
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// PrometheusAgentJsonCfg holds the unparsed prometheus_agent as found in the config file.
|
||||
type PrometheusAgentJsonCfg struct {
|
||||
Enabled *bool `json:"enabled"`
|
||||
Path *string `json:"path"`
|
||||
CollectGoMetrics *bool `json:"collect_go_metrics"`
|
||||
CollectProcessMetrics *bool `json:"collect_process_metrics"`
|
||||
CoreSConns *[]string `json:"cores_conns"`
|
||||
StatSConns *[]string `json:"stats_conns"`
|
||||
StatQueueIDs *[]string `json:"stat_queue_ids"`
|
||||
}
|
||||
|
||||
// PrometheusAgentCfg represents the configuration of the Prometheus Agent.
|
||||
type PrometheusAgentCfg struct {
|
||||
Enabled bool
|
||||
Path string
|
||||
CollectGoMetrics bool
|
||||
CollectProcessMetrics bool
|
||||
CoreSConns []string
|
||||
StatSConns []string
|
||||
StatQueueIDs []string
|
||||
}
|
||||
|
||||
func (c *PrometheusAgentCfg) loadFromJSONCfg(jc *PrometheusAgentJsonCfg) error {
|
||||
if jc == nil {
|
||||
return nil
|
||||
}
|
||||
if jc.Enabled != nil {
|
||||
c.Enabled = *jc.Enabled
|
||||
}
|
||||
if jc.Path != nil {
|
||||
c.Path = *jc.Path
|
||||
}
|
||||
if jc.CollectGoMetrics != nil {
|
||||
c.CollectGoMetrics = *jc.CollectGoMetrics
|
||||
}
|
||||
if jc.CollectProcessMetrics != nil {
|
||||
c.CollectProcessMetrics = *jc.CollectProcessMetrics
|
||||
}
|
||||
if jc.CoreSConns != nil {
|
||||
c.CoreSConns = tagInternalConns(*jc.CoreSConns, utils.MetaStats)
|
||||
}
|
||||
if jc.StatSConns != nil {
|
||||
c.StatSConns = tagInternalConns(*jc.StatSConns, utils.MetaStats)
|
||||
c.StatSConns = make([]string, len(*jc.StatSConns))
|
||||
for idx, connID := range *jc.StatSConns {
|
||||
c.StatSConns[idx] = connID
|
||||
if connID == utils.MetaInternal {
|
||||
c.StatSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaStats)
|
||||
}
|
||||
}
|
||||
}
|
||||
if jc.StatQueueIDs != nil {
|
||||
c.StatQueueIDs = *jc.StatQueueIDs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AsMapInterface returns the prometheus_agent config as a map[string]any.
|
||||
func (c PrometheusAgentCfg) AsMapInterface() any {
|
||||
return map[string]any{
|
||||
utils.EnabledCfg: c.Enabled,
|
||||
utils.PathCfg: c.Path,
|
||||
utils.CollectGoMetricsCfg: c.CollectGoMetrics,
|
||||
utils.CollectProcessMetricsCfg: c.CollectProcessMetrics,
|
||||
utils.CoreSConnsCfg: stripInternalConns(c.CoreSConns),
|
||||
utils.StatSConnsCfg: stripInternalConns(c.StatSConns),
|
||||
utils.StatQueueIDsCfg: c.StatQueueIDs,
|
||||
}
|
||||
}
|
||||
|
||||
// Clone returns a deep copy of PrometheusAgentCfg.
|
||||
func (c PrometheusAgentCfg) Clone() *PrometheusAgentCfg {
|
||||
return &PrometheusAgentCfg{
|
||||
Enabled: c.Enabled,
|
||||
Path: c.Path,
|
||||
CollectGoMetrics: c.CollectGoMetrics,
|
||||
CollectProcessMetrics: c.CollectProcessMetrics,
|
||||
CoreSConns: slices.Clone(c.CoreSConns),
|
||||
StatSConns: slices.Clone(c.StatSConns),
|
||||
StatQueueIDs: slices.Clone(c.StatQueueIDs),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user