Aggregate Traces

This section demonstrates how to perform aggregation operations on trace data using the SigNoz Trace API.

Aggregation Example

This example is useful for scenarios where you need to count occurrences of specific values (e.g., customer) and group them by another attribute (e.g., serviceName).

Query Description

  • Objective: Count customer values and group them by serviceName
  • Attributes:
    • aggregateAttribute: customer
    • groupBy: serviceName

Sample Payload

This is the JSON payload for the example query.

{
    "start": 1702019380000,
    "end": 1702021180000,
    "step": 60,
    "variables": {},
    "compositeQuery": {
        "queryType": "builder",
        "panelType": "table",
        "builderQueries": {
            "A": {
                "dataSource": "traces",
                "queryName": "A",
                "aggregateOperator": "count",
                "aggregateAttribute": {
                    "key": "customer",
                    "dataType": "string",
                    "type": "tag",
                    "isColumn": false
                },
                "filters": {
                    "items": [],
                    "op": "AND"
                },
                "expression": "A",
                "disabled": false,
                "having": [],
                "stepInterval": 60,
                "limit": null,
                "orderBy": [
                    {
                        "columnName": "timestamp",
                        "order": "desc"
                    }
                ],
                "groupBy": [
                    {
                        "key": "serviceName",
                        "dataType": "string",
                        "type": "tag",
                        "isColumn": true
                    }
                ],
                "legend": "",
                "reduceTo": "sum"
            }
        }
    },
    "dataSource": "traces"
}

Was this page helpful?