v2.1Guide
Query language
Syntax of the short filter queries: comparisons, substrings, AND, OR and NOT.
A query is a string compiled into a function (rec) => boolean. The query parser is hand-written, evaluates nothing through eval and never runs code from the string.
const isProblem = parser.query('level>=warn AND NOT msg~"health"');Operators#
| Operator | Meaning | Example |
|---|---|---|
: | equals | status:404, method:GET |
> >= < <= | compare numbers, levels and dates | bytes>1000000, level>=warn |
~ | contains a substring, case-insensitive | msg~"timeout" |
:5xx | status class mask | status:5xx |
AND OR NOT | logic, parentheses allowed | (a OR b) AND NOT c |
Two conditions in a row without a word between them mean AND: level>=warn status:5xx.
What can be compared#
- The names
ts,levelandmsgbelong to the record; anything else is looked up inrec.fields. - Levels are ordered:
trace < debug < info < warn < error < fatal. - Dates are written as
2026-10-01or2026-10-01T09:00:00Z.ts>2026-10-01compares with midnight UTC. - If the record lacks the field, the condition is false, not an error. The exception is
NOT:NOT status:200is true for a record withoutstatus.
Examples#
level>=error
status:5xx AND path~"/api/"
ts>2026-10-01T09:00:00Z AND ts<2026-10-01T10:00:00Z
(service:db OR service:cache) AND level>=warnQuery errors#
A malformed query throws ParseError with code E_QUERY_SYNTAX and the character position. The query is validated once at compile time, not on every record.
Quoted strings
Put values containing spaces in double quotes: msg~"connection reset". Single quotes are not supported so that a query works unchanged inside a single-quoted shell argument.