Skip to main content
Log search has no free-text query language. You ask in plain language, and Sazabi turns the question into a structured query. That query is a JSON object called the log query spec, and you can write one yourself to run exactly what you mean. This page is the reference for that spec. For asking questions, see Search logs.

Run a spec

Run a spec with the CLI. Pass it as one quoted JSON argument, as @file.json, or as - to read standard input:
To start from a query you already asked, save its spec, edit it, and run the edited file:
npx -y @sazabi/cli@latest logs query schema prints the spec’s JSON Schema, for an editor or a validator. A spec the service cannot run is refused with each problem and where it is. The API takes the same object as spec on POST /v1/logs/queries/execute; see Run a log query. Pass either spec or queryId, not both.

Shape of a spec

Unknown members are refused. The time window is not part of the spec; see Time range.

Predicate

A predicate is a tree. Each node is one of and, or, not, or compare.

Boolean logic

Comparators

There are no wildcard or regular-expression operators. Use contains for a substring and starts_with for a prefix. Values are strings, numbers, booleans, or null, with strings up to 8,192 characters. exists takes no value; every other comparator requires one, and in requires an array. The ordering comparators need a numeric value, and a field that does not read as a number never matches them. severity is the exception: it takes level names, covered next. A predicate can have at most 50 children per node, 8 levels of nesting, 200 nodes, and 65,536 characters of values in total.

Fields

Every compare, dimension, and measure names a field with a kind. severity compares with eq, neq, in, gt, gte, lt, lte, and exists, and only with level names. gte with "WARN" means warnings and worse. To match the text the sender wrote, use the severity_text column. The column names are:
  • severity_text, trace_id, span_id
  • deployment.environment, k8s.pod.name, event.name
  • http.request.method, http.route, url.path, http.response.status_code, operation_kind, server.address, http.request.body.size, http.response.body.size
A query that uses any of the http.*, url.path, operation_kind, or server.address columns reads request records only, each request once, so other lines a request writes are not counted as requests.

Measure

measure is what to compute over the lines the predicate selects.

Group, rank, and output

dimensions groups results by up to three fields. output shapes the result:
  • table returns one value, or one row per group.
  • series returns one value per time bucket and group. Set bucket to 1m, 5m, 10m, 15m, 30m, 1h, 6h, 12h, 1d, or 1w.
  • evidence returns the lines themselves. It goes with the recent_rows measure, and only with that measure.
Groups are ranked by value, largest first. Set order to {"by":"value","direction":"asc"} for the smallest first, or {"by":"dimension","direction":"asc"} to order by the group’s own values, which needs exactly one dimension. series keeps the first limit groups, up to 10,000, and with "overflow":"other" folds the rest into one group, or with "overflow":"drop" leaves them out. "times": true adds the first and last matching line’s time to each result. It does not go with recent_rows, whose lines carry their own times.

Time range

A spec has no time range. Give the window when you run it:
  • --since is a relative window ending now: whole minutes, hours, or days, such as 30m, 6h, or 7d, up to 90d.
  • --from and --to are an absolute window as ISO-8601 times. Give both, with --from before --to.
  • With neither, a spec runs over the last hour. --since cannot be combined with --from or --to.
The API takes window as {"kind":"relative","lookbackSeconds":21600} or {"kind":"absolute","from":"...","to":"..."}. A relative window reaches back at most 90 days, and you can search only the logs your project still keeps; see Log storage & retention. --limit sets the page size, 1 to 5,000 and 50 by default. Matching lines page with --cursor; see Page through matching lines.

Examples

Each example is a spec file you can run with npx -y @sazabi/cli@latest logs query execute @query.json --since 6h. Errors and worse per service:
The 20 newest checkout lines that carry an order.id attribute:
Errors per service every 15 minutes, for the top five services:
Average duration from a JSON field, per service:
The p95 latency of api requests per route, slowest first:
The share of api lines that are errors, with when the first and last error happened:

Further reading

Search logs

Ask questions in plain language and rerun the queries behind them.

Run a log query

The API operation that runs a spec.