Lucene and KQL log filters
POST /v1/projects/{p}/query/search with {"language": "lucene" | "kql", "q": "...", "from", "to"} returns the newest matching log lines (at most 1,000). Both languages compile to SQL over the logs table and run through the tenant-safe SQL surface, so the project scope, the time range, the function allow-list, the memory limit and the concurrency caps are the same as for /query/sql.
Fields: service, severity_text (severity, level), severity_number, body (message, msg), trace_id, span_id, ts_ns. Any other name is a log attribute; resource.name reads a resource attribute. Words without a field search the log body, ignoring case. severity_text is compared ignoring case.
Lucene
Syntax | Meaning |
|---|---|
| body contains |
| field equals value |
| phrase in the body (exact value on other fields; for a substring use |
| wildcards ( |
| range, |
| boolean operators (uppercase words) |
| required, prohibited, optional |
| field applied to a group |
| the field is present |
Clauses written next to each other are OR (the Lucene default). When a query has required (+) clauses, the optional ones are ignored. Numeric ranges compare numbers when both bounds are numbers; otherwise they compare text.
KQL
Syntax | Meaning |
|---|---|
| field equals value |
| field applied to a group |
|
|
| comparison |
| nested fields, meaning |
| the field is present |
| RE2 regular expression, at most 1,024 bytes; ClickHouse runs RE2 in linear time |
Limits
Queries are at most 8 KiB, 64 terms and 16 levels deep. Syntax errors return 422 with a fixed message and the character position (syntax error at 5: expected a term). Unknown fields are treated as attributes; a number field given text, or a pattern on a number field, returns 422.