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.sumscome in the order ofmetrics.groupBy:"all"(the default),{"field": "model"}(alsotraceId,kind,userId,sessionId,name,tag),{"attribute": "user.plan"}, or{"time": {"bucketMs": 3600000}}.filter: a span filter, as in Filter spans.
null:
sort by a sum ({"sum": 0} is the first metric), by count, or by a percentile; "order": "asc" turns it around:
"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:
thenBy (a field or an attribute). key is the bucket and key2 the value. Cost per model per second:
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.
null: no span of the group has a cost.
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).