Updates on prometheus code

This commit is contained in:
porosnicuadrian
2022-01-05 08:31:10 +02:00
committed by Dan Christian Bogos
parent 40c6b6ac29
commit 04f77ad5e4
6 changed files with 21 additions and 8 deletions

View File

@@ -151,6 +151,7 @@ func testServeHHTPFail(t *testing.T) {
"invalid_port_format",
cfgDflt.HTTPCfg().JsonRPCURL,
cfgDflt.HTTPCfg().WSURL,
cfgDflt.HTTPCfg().PrometheusURL,
cfgDflt.HTTPCfg().UseBasicAuth,
cfgDflt.HTTPCfg().AuthUsers,
)

View File

@@ -127,7 +127,7 @@
"attempts": 1,
"field_separator": ",",
"synchronous": true,
"fields":[
"fields":[
{"tag": "Number", "path": "*hdr.Number", "type": "*constant", "value": "NumberOfEvent"},
{"tag": "CGRID", "path": "*hdr.CGRID", "type": "*constant", "value": "CGRID"},
{"tag": "RunID", "path": "*hdr.RunID", "type": "*constant", "value": "RunID"},

View File

@@ -30,12 +30,12 @@
"enabled": true,
"store_interval": "-1",
"thresholds_conns": ["*internal"],
"opts": { //
"*prometheusMetrics": [
"opts": {
"*prometheusStatIDs": [
{
"Tenant": "*any",
"FilterIDs": [],
"Value": ["SQ_1", "SQ_2"],
"Value": ["SQ_1"],
},
],
},

View File

@@ -854,7 +854,10 @@ func exportToPrometheus(matchSQs StatQueues, promIDs utils.StringSet) (err error
if _, has := promIDs[qos.ID]; !has {
continue
}
tntID := strings.Replace(qos.TenantID(), ".", "_", -1)
tntID, err := getStatTenantID(qos.TenantID())
if err != nil {
return err
}
gaugeVal := prometheus.NewGaugeVec(prometheus.GaugeOpts{
Subsystem: "stats",
Name: tntID,
@@ -877,3 +880,12 @@ func exportToPrometheus(matchSQs StatQueues, promIDs utils.StringSet) (err error
}
return
}
func getStatTenantID(tntID string) (promTntID string, err error) {
for _, char := range tntID {
if strings.ContainsAny(string(char), `/,.'"\`) {
tntID = strings.Replace(tntID, string(char), "_", -1)
}
}
return tntID, nil
}

View File

@@ -342,8 +342,8 @@ func (sS *StatS) processEvent(ctx *context.Context, tnt string, args *utils.CGRE
}
var promIDs []string
if promIDs, err = GetStringSliceOpts(ctx, tnt, args, sS.fltrS, sS.cfg.StatSCfg().Opts.PrometheusMetrics,
[]string{}, utils.OptsPrometheusMetrics); err != nil {
if promIDs, err = GetStringSliceOpts(ctx, tnt, args, sS.fltrS, sS.cfg.StatSCfg().Opts.PrometheusStatIDs,
[]string{}, utils.OptsPrometheusStatIDs); err != nil {
return
}
if len(promIDs) != 0 {

View File

@@ -2334,7 +2334,7 @@ const (
// Stats
OptsStatsProfileIDs = "*statsProfileIDs"
OptsRoundingDecimals = "*roundingDecimals"
OptsPrometheusMetrics = "*prometheusMetrics"
OptsPrometheusStatIDs = "*prometheusStatIDs"
// Thresholds
OptsThresholdsProfileIDs = "*thdProfileIDs"