Skip to main content
POST /v1/aggregate counts the spans that match a filter, and sums their numbers, per group. Right: read.

Body

object
default:"{}"
A span filter. Left out: every span.
string | object
default:"all"
The key of a group.
object
A second key, for a time series per value. groupBy must be a time bucket, and thenBy a field or an attribute: else 400. Each row is one bucket and one value: key is the bucket, key2 the value. Rows come by bucket (oldest first), and inside a bucket in the order of the series.
string[]
default:"[]"
The exact sums to compute per group. sums in each row has the same order.
object[]
default:"[]"
Percentiles per group: [{"p": 95}, {"p": 99.9, "approx": true}, {"p": 95, "of": "costNanos"}].Spans with no value do not count: for the duration, spans that have not ended; for a cost, spans with no such cost; for the time to first token, spans with none. A group where no span has a value gets null.
object
Rows by one value instead of by key: {"by": "count" | {"sum": i} | {"percentile": i}, "order": "desc" | "asc"}. i is an index into the row’s sums or percentiles. order defaults to "desc". Ties by key; null values last. Left out: rows by key.
integer
Keep this many rows, after the sort (top N). Left out: every row.
With thenBy, sort and limit choose whole series, not rows. A series is one value of thenBy over all buckets. The server puts the series in order by their count, sum or percentile over all matching spans, keeps the first limit, and returns every bucket of each. The 10 users with the highest cost, each with all its days: {"groupBy": {"time": {"bucketMs": 86400000}}, "thenBy": {"field": "userId"}, "metrics": ["costNanos"], "sort": {"by": {"sum": 0}}, "limit": 10}.

Answer

object[]
One row per group. Rows by key: null, then text, then true and false, then numbers.
  • With no percentiles, a filter on kind, model and time only (also as a tree of and, or, not) reads saved sums: one row per hour, kind and model. It reads spans only for the parts of the time range that are not whole hours.
  • The groups that the saved sums can give: "all", kind, model, buckets of whole hours, and buckets of whole hours with thenBy kind or model.
  • Every other query visits every matching span: another field, a tag, an attribute, a bucket that is not whole hours, any percentile.
  • A group by attribute also reads, in each part of the store, the list of spans of every value of the path. A path with very many values is slow.

Add up numbers

A guide with real sums, series and percentiles.

Sums of scores

Averages and label counts of eval scores.