mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updates on prometheus code
This commit is contained in:
committed by
Dan Christian Bogos
parent
40c6b6ac29
commit
04f77ad5e4
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -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"],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -2334,7 +2334,7 @@ const (
|
||||
// Stats
|
||||
OptsStatsProfileIDs = "*statsProfileIDs"
|
||||
OptsRoundingDecimals = "*roundingDecimals"
|
||||
OptsPrometheusMetrics = "*prometheusMetrics"
|
||||
OptsPrometheusStatIDs = "*prometheusStatIDs"
|
||||
|
||||
// Thresholds
|
||||
OptsThresholdsProfileIDs = "*thdProfileIDs"
|
||||
|
||||
Reference in New Issue
Block a user