stats metrics id alias name possibilty

23 views
Skip to first unread message

ryan embgrets

unread,
Jun 1, 2021, 5:21:06 PM6/1/21
to cgr...@googlegroups.com
Greetings, 

From my understanding stats are bound to metrics id which should be unique. You cannot have duplicate metrics id. This limits the possibility to create multiple stats queue when you get only two unique values, per call

1. CGRID
2. OriginID

For example below stats, 

{
  "_id": ObjectId("5fbd6c0f56be3723844270ce"),
  "id": "5fbd6c0f5129f004aeaefa60",
  "tpid": "1",
  "activationinterval": {
    "activationtime": "2014-07-29T15:00:00Z",
    "expirytime": ""
  },
  "blocker": false,
  "filterids": [
    "FLTR_5fbd6c0f5129f004aeaefa60"
  ],
  "metrics": [
    {
      "filterids": null,
      "metricid": "*distinct#~*req.CGRID"
    },
    {
      "filterids": [
        "*string:~*req.HangupCause:OK"
      ],
      "metricid": "*distinct#~*req.OriginID"
    }
  ],
  "minitems": NumberInt("0"),
  "queuelength": NumberInt("-1"),
  "stored": false,
  "tenant": "cgrates.org",
  "thresholdids": [
    "*none"
  ],
  "ttl": "24h",
  "weight": NumberInt("5")
}

I cannot create another one stats query based upon different filters but having the same metrics Id. (There are only two unique fields so i don't have much choice). 

Maybe it would be nice if we can refer to metrics id through some alias, something like below. 


 "metrics": [
    {
      "filterids": null,
      "metricid": "*distinct#~*req.CGRID;alias=totalCalls"
    },
    {
      "filterids": [
        "*string:~*req.HangupCause:OK"
      ],
      "metricid": "*distinct#~*req.OriginID;alias=successfulCalls"
    },
    {
      "filterids": [
        "*lt:~*req.Usage:6s"
      ],
      "metricid": "*distinct#~*req.OriginID;alias=shortCalls"
    }
  ],

Ryan

ryan embgrets

unread,
Jun 2, 2021, 3:01:51 AM6/2/21
to cgr...@googlegroups.com
I can circumvent this if there is a way to simply do a count of metrics. 

I think a count filter rule will be really nice. Because sometimes I really want a simple count instead of a distinct count. 

Is there a way to perform a simple count in stats instead of using the distinct filter rule?  This will actually let me use other metrics ID, like account for the stats. 

Ryan. 

Alexandru Tripon

unread,
Jun 8, 2021, 6:24:04 AM6/8/21
to cgr...@googlegroups.com
Hy Ryan,

In this case, we recommend you to have multiple stats Queue profiles with filters on them, not on metrics.
e.g.
```
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],QueueLength[4],TTL[5],MinItems[6],Metrics[7],MetricFilterIDs[8],Stored[9],Blocker[10],Weight[11],ThresholdIDs[12]
cgrates.org,StatTotalCalls,FLTR_5fbd6c0f5129f004aeaefa60,,-1,24h,0,*distinct#~*req.CGRID,,false,false,5,*none
cgrates.org,StatSuccessfulCalls,FLTR_5fbd6c0f5129f004aeaefa60;*string:~*req.HangupCause:OK,,-1,24h,0,*distinct#~*req.CGRID,,false,false,5,*none
cgrates.org,StatShortCalls,FLTR_5fbd6c0f5129f004aeaefa60;*lt:~*req.Usage:6s,,-1,24h,0,*distinct#~*req.CGRID,,false,false,5,*none
```

Thanks,
Trial97


--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/CAJ_X8k41X8L8BXrEEd5NHMms3aOW4JHTYAE3%3DSY-H9OH48p_rQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages