StatS is a standalone subsystem part of the CGRateS infrastructure, designed to aggregate and calculate statistical metrics for the generic Events (hashmaps) it receives.

Both receiving of Events as well as Metrics displaying is performed via a complete set of CGRateS RPC APIs.

Due it’s real-time nature, StatS are designed towards high throughput being able to process thousands of Events per second. This is doable since each StatQueue is a very light object, held in memory and eventually backed up in DataDB.

Processing logic

When a new Event is received, StatS will pass it to FilterS in order to find all StatProfiles matching the Event.

As a result of the selection process we will further get an ordered list of StatProfiles which are matching the Event and are active at the request time.

For each of these profiles we will further calculate the metrics it has configured for the Event received. If ThresholdIDs are not *none, we will include the Metrics into special StatUpdate events, defined internally, and pass them further to the [ThresholdS](ThresholdS) for processing.

Depending on configuration each StatQueue can be backed up regularly and asynchronously to DataDB so it can survive process restarts.



StatS is the CGRateS component responsible of handling the StatQueues.

It is configured within stats section from JSON configuration via the following parameters:


Will enable starting of the service. Possible values: <true|false>.


Time interval for backing up the stats into DataDB.


After this limit is hit the events within StatQueue will be stored aggregated.


Connections IDs towards ThresholdS component. If not defined, there will be no notifications sent to ThresholdS on StatQueue changes.


Enable profile matching exclusively on indexes. If not enabled, the StatQueues are checked one by one which for a larger number can slow down the processing time. Possible values: <true|false>.


Query string indexes based only on these fields for faster processing. If commented out, each field from the event will be checked against indexes. If uncommented and defined as empty list, no fields will be checked.


Query prefix indexes based only on these fields for faster processing. If defined as empty list, no fields will be checked.


Applied when all event fields are checked against indexes, and decides whether subfields are also checked.


Ís made of the following fields:


The tenant on the platform (one can see the tenant as partition ID).


Identifier for the StatQueueProfile, unique within a Tenant.


List of FilterProfileIDs which should match in order to consider the profile matching the event.


The time interval when this profile becomes active. If undefined, the profile is always active. Other options are start time, end time or both.


Maximum number of items stored in the queue. Once the QueueLength is reached, new items entering will cause oldest one to be dropped (FIFO mode).


Time duration causing items in the queue to expire and be removed automatically from the queue.


List of statistical metrics to build for items within this StatQueue. See [bellow](#statqueue-metrics) for possible values here.


List of threshold IDs to check on when new items are updating the queue metrics.


Do not process further StatQueues.


Enable offline backups for this StatQueue


Order the StatQueues matching the event. Higher value - higher priority.


Display metrics only if the number of items in the queue is higher than this.

StatQueue Metrics

Following metrics are implemented:


Answer-seizure ratio. Relies on AnswerTime field in the Event.


Average call duration. Uses AnswerTime and Usage fields in the Event.


Total call duration. Uses Usage out of Event.


Average call cost. Uses Cost field out of Event.


Total call cost. Uses Cost field out of Event.


Post dial delay <>. Uses PDD field in the event.


Distinct destination count will keep the number of unique destinations found in Events. Relies on Destination field in the Event.


Generic metric to calculate mathematical sum for a specific field in the Events. Format: <*sum#FieldName>.


Generic metric to calculate the mathematical average of a specific field in the Events. Format: <*average#FieldName>.


Generic metric to return the distinct number of appearance of a field name within Events. Format: <*distinct#FieldName>.

Use cases

  • Aggregate various traffic metrics for traffic transparency.

  • Revenue assurance applications.

  • Fraud detection by aggregating specific billing metrics during sensitive time intervals (*acc, *tcc, *tcd).

  • Building call patterns.

  • Building statistical information to train systems capable of artificial intelligence.

  • Building quality metrics used in traffic routing.