Skip to main content
POST /v1/aggregate: the count of spans, and exact sums, per group.
  • metrics: inputTokens, outputTokens, totalTokens, costNanos, durationMs, errorCount, cacheReadTokens, cacheWriteTokens, reasoningTokens, inputCostNanos, outputCostNanos, timeToFirstTokenMs. sums come in the order of metrics.
  • groupBy: "all" (the default), {"field": "model"} (also traceId, kind, userId, sessionId, name, tag), {"attribute": "user.plan"}, or {"time": {"bucketMs": 3600000}}.
  • filter: a span filter, as in Filter spans.
One group, every metric:
Tokens per model. Spans with no model have the key null:
Top N. The user with the highest cost. sort by a sum ({"sum": 0} is the first metric), by count, or by a percentile; "order": "asc" turns it around:
By an attribute. The key keeps its type ("1", 1 and true are three groups):

Time series

{"time": {"bucketMs": ...}} groups by time. Buckets start at the Unix epoch, so a bucket of a day is a UTC day. Only buckets with a span come back: a chart fills the others with zero. Root spans per second:
A series per value: add thenBy (a field or an attribute). key is the bucket and key2 the value. Cost per model per second:
With thenBy, sort and limit choose whole series: "sort": {"by": {"sum": 0}}, "limit": 10 gives the 10 values with the highest sum over all buckets, each with every bucket.

Percentiles

percentiles: [{"p": 95}] is the 95th percentile of the duration. of picks another value (costNanos, totalTokens, inputTokens, outputTokens, timeToFirstTokenMs, …). Exact by default (the nearest-rank rule). Spans with no value do not count: a span that has not ended has no duration.
"approx": true uses a sketch: at most 1% off, and small memory for any number of spans.
Percentiles of cost and of tokens, per kind. null: no span of the group has a cost.
How fast a sum is: a sum with a filter on kind, model and time only, grouped by kind, model or whole hours, reads saved sums per hour. Every other sum visits each matching span (limits).