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:
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 ofand, 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
Everycompare, 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_iddeployment.environment,k8s.pod.name,event.namehttp.request.method,http.route,url.path,http.response.status_code,operation_kind,server.address,http.request.body.size,http.response.body.size
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:
tablereturns one value, or one row per group.seriesreturns one value per time bucket and group. Setbucketto1m,5m,10m,15m,30m,1h,6h,12h,1d, or1w.evidencereturns the lines themselves. It goes with therecent_rowsmeasure, and only with that measure.
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:--sinceis a relative window ending now: whole minutes, hours, or days, such as30m,6h, or7d, up to90d.--fromand--toare an absolute window as ISO-8601 times. Give both, with--frombefore--to.- With neither, a spec runs over the last hour.
--sincecannot be combined with--fromor--to.
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 withnpx -y @sazabi/cli@latest logs query execute @query.json --since 6h.
Errors and worse per service:
order.id attribute:
api requests per route, slowest first:
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.