Log Analytics query language
A query reads one project's logs (customer logs, platform events and build output) in the time range chosen next to the query. It is a search, then pipe operators: search | op | op. The gateway compiles it to LogsQL for VictoriaLogs (lab and production) and evaluates it in memory on a backend with no LogsQL. The project is never part of the text: the gateway adds it, so no query can read another project's logs (ADR-0803).
Fields
timestamp, severity (TRACE < DEBUG < INFO < WARN < ERROR < FATAL), service, message, resource, trace_id, span_id; every other name is an attribute of the record or a field made by parse json or extract. Names start with a letter and hold letters, digits, _, . and -. Text goes in double quotes (\" and \\ escape).
Search and where
- A word or "string" is a case-insensitive match in the message: timeout, "connection reset". - field = value, !=, >, >=, <, <= (numbers; severity by order), ~ and !~ (regular expression, linear time: no look-around or back-references, at most 256 characters), contains, startswith, endswith (case-insensitive), field in ("a", "b"). - not binds tightest, then and, then or; terms next to each other mean and. * matches everything.
Operators
| Operator | Does | |
|---|---|---|
where <filter> | Keep rows that match. | |
parse json [from field] | Add the fields of a JSON object (default: the message); nested names are joined with .. | |
extract "took <ms>ms for <page>" [from field] | Add the placeholders' text as fields; <_> skips text. A row without a match is unchanged. | |
project a, b | Keep these columns, in this order. | |
summarize <aggs> [by f, bin(timestamp, 5m)] | count(), count(f), sum(f), avg(f), min(f), max(f), dcount(f), percentile(f, 95), p50/p90/p95/p99(f); as name renames. Bins are 1s to 7d; with a bin the rows come in time order. | |
| `sort by f [asc\ | desc], …` | Numbers compare as numbers. |
take N | The first N rows (at most 10000). | |
top N by f | The N most frequent values, with count. | |
| `join [inner\ | left] on field (key, col, …) [("k", "v", …), …]` | Add columns from a lookup table written in the query (at most 1000 rows, 8 columns). left keeps rows with no match. Operators after a join run in the gateway. |
Limits: 4096 characters, 20 operators, 100 values in an in list, nesting 24. An aggregate on the gateway path reads at most 500 records (truncated says when it was cut); on VictoriaLogs it reads up to 10000 rows.
Errors
A refused query answers with the message, the offset, the length, the line and the column of the fault. The console underlines it.
Examples
service=api severity>=ERROR | summarize count() by bin(timestamp, 5m)
"took" | extract "took <ms>ms" | summarize p95(ms), avg(ms) by service
| parse json | where status >= 500 | top 10 by path
| join left on service (service, team) [("api", "core"), ("web", "front")] | summarize count() by team