On this page
Query Language (ObiQL)
The query language every search, saved query, alert, and dashboard panel compiles to.
ObiQL is one language behind everything that touches your data: typing in the Explorer's search bar, Live Tail's filter, and (as those features ship) saved queries, alert conditions, and dashboard panels all produce the same ObiQL AST, compiled to the same ClickHouse SQL underneath.
The shape of a query
A bare term is a free-text search:
timeout
Add field filters by writing field="value":
service="checkout-api" level="error"
Adjacent filters are implicitly ANDed together. Pipe (|) into a stage to
transform or aggregate the result:
service="checkout-api" level="error" | stats count() by service
Excluding a phrase
Put - or NOT in front of any term to drop the events it matches. To leave
out a noisy message, negate the quoted phrase on its own, with no field name:
level="error" -"Error: Failed to find Server Action"
A quoted phrase with no field name matches anywhere in the event, so this
drops every event containing that text, including ones where more follows it.
A field filter like -message="Error: Failed to find Server Action" can
require the whole value to match, and then a line with anything after the
phrase is not excluded.
Wildcards
* matches any run of characters and ? matches exactly one, on any field:
service=pay* level=err?r
Wildcards only apply to an unquoted value. service="pay*" searches for a
literal asterisk, which is how you look for one.
field=* on its own asks whether the field is set at all, and matches events
carrying a non-empty value for it:
checkout_id=*
Negate it to find the events missing the field, either way round:
checkout_id!=*
NOT checkout_id=*
This works on every field, including timestamps and numbers. A wildcard with
a literal character beside it does not: @timestamp=2026-07-* is an error,
because a timestamp needs a range (@timestamp=[2026-07-01 TO 2026-07-31]).
Case
Field names and values are matched without regard to case. All four of
these are the same query, and all four match an event whose sender wrote
Hostname: WEB-1:
hostname=web-1
HOSTNAME=web-1
hostname=WEB-1
HostName=Web-1
That covers the common case, which is that nobody remembers whether the
service that emitted a log line spelled its field hostname, hostName or
HOSTNAME. Free-text terms, wildcards and ranges fold case the same way, so
level=ERR* and level=error never disagree.
When you do need the exact spelling, wrap either side in case(...):
case("HOSTNAME")=web-1 # only events whose field is literally HOSTNAME
hostname=case("WEB-1") # only events whose value is literally WEB-1
case("HOSTNAME")=case("test") # both, so `hostname=TEST` does not match
case(...) around a platform field (@timestamp, _source_name,
_service_type, _event_id) does nothing: those names have exactly one
spelling, so there is no ambiguity to resolve. Around a number it does
nothing either.
Pipe stages
A query is zero or more filters followed by zero or more pipe stages, each one operating on the output of the stage before it - the same mental model as a Unix pipeline. See the generated reference for every stage ObiQL ships today, with its aliases and an example for each.
then works anywhere | does, if that reads better to you:
service="checkout-api" level="error" then stats count() by service
The two are the same query. | is the form we write in the docs and the form
the query builder produces; then is only read. It has to be followed by a
stage name to count as one, so a search for the word itself still works.
Two stages worth knowing early:
level="error" | timechart span=5m count() by service
level="error" | fields timestamp, service, message
timechart buckets the matches over time and draws them as a chart - the same
chart a dashboard time-series panel draws, because it is the same query.
span=5m fixes the bucket width. Leave span off and the width follows the
time range instead: about sixty buckets across whatever window you are looking
at, so zooming in on a chart gives you finer buckets.
fields (or table, the same stage) picks which columns come back, and the
results table follows it.
The current value of a metric
max() and avg() summarise a whole time range. For a gauge such as disk or
memory use you usually want what it reads right now, which is what latest()
returns: the field's value on the newest event that has a number for it.
metric.name=system.filesystem.utilization | stats latest(metric.value) AS disk_used
latest() works in stats and timechart, where it gives the last reading in
each bucket.
Pulling fields out of a message
Not every log line arrives structured. A plain text line lands with its whole
content in message, which you can search but cannot group by. extract
fixes that for the duration of one query - no reindexing, and it works on
events you already stored:
| extract pattern="<ip> - - <_> \"<method> <uri>\" <status>" | stats count() by status
Each <name> becomes a new field you can filter, sort and aggregate on for
the rest of the pipeline. <_> skips a run of text you do not want a column
for. The pattern is matched from the start of the line, and anything after the
last placeholder is ignored, so you only have to describe the part you care
about.
When the text is too irregular for placeholders, give it a regular expression
instead. Only named groups become fields, so a plain (...) is grouping
rather than a surprise column:
| extract regex="status=(?<status>\d{3})"
rex is an accepted spelling of the same stage, and takes a bare quoted
regex, so a search pasted from Splunk works unchanged:
| rex field=message "status=(?<status>\d{3})"
field= says which field to read from, and defaults to message. A line that
does not match the pattern still comes back - the extracted fields are just
empty for it. And because an extracted name shadows a stored field of the same
name, | extract is also how you reinterpret a field that was parsed wrongly
at ingest, without touching what is stored.
Grouping events by shape: _pattern and _punct
Grouping by message puts nearly every line in its own bucket, because each
one carries a different id, timestamp or duration. Two built-in fields fix
that.
Both read the whole event, not just its message: every field it carries,
written as key=value pairs sorted by key. Events with no
message, such as metric data points, have them too.
{"service":"payments","level":"error","message":"user 44821 not found"}
level=error message=user 44821 not found service=payments
_pattern is that with the variable part of each value replaced by
placeholders. The keys and words stay, so two different errors stay two
patterns:
| In a value | Becomes |
|---|---|
A URL with a scheme (https://..., s3://...) | <url> |
| An email address | <email> |
| A UUID | <uuid> |
| An IPv4 or IPv6 address | <ip> |
| An ISO-8601, SQL, access-log or syslog timestamp, or a time of day | <time> |
0x..., or a hex id of eight characters or more | <hex> |
| A number, decimal or dotted version | <n> |
| A quoted JSON value (the keys are kept) | "<str>" |
level=error message=Connection to 10.0.3.14:5432 failed after 250ms (req 8f2c1e90-4b1a-4c2d-9f31-0a1b2c3d4e5f)
level=error message=Connection to <ip>:<n> failed after <n>ms (req <uuid>)
level=error | stats count() by _pattern | sort -count
_punct works like Splunk's punct: the punctuation of the event's first
line, keys included, in order, with letters, digits and non-ASCII characters
removed. Each space is written _ and each tab t, leading and trailing
whitespace is ignored, and the value stops at 30 characters. It tells formats apart rather
than messages, which makes it a quick way to find the lines a parser did not
expect:
message=10.0.3.14 - - [19/Sep/2026:10:00:00 +0000] "GET /api HTTP/1.1" 200 512
=..._-_-_[//:::_+]_"_/_/."__
service=nginx | stats count() by _punct | sort count
Both are computed when a query names them, so they work on every event you
have already stored and cost nothing at ingest. They work in
filters, stats, sort, table, alert rules, dashboards and Live Tail.
Reading JSON out of a field
A lot of log lines are a JSON object logged as text. The line arrives whole,
in message, and every key inside it is invisible to a filter or a stats:
{"tag":"unsupported_currency","at":"pricing_viewed","country":"SE","fellBackTo":"usd"}
json reads into it. With nothing after the field name, it gives you a column
for every key it finds:
| json field=message
That is usually all you need. tag, at, country and fellBackTo become
real columns, and every stage after the | json can use them:
service="pricing" | json field=message | stats count() by country
The keys come from the events themselves - a sample of the ones your search matches - so you do not have to know what is in there before you ask. A key that only some events carry still gets a column; the events without it are blank rather than missing.
Naming the paths yourself
Name them when you want fewer columns, or a key that is nested, or a different column name:
| json field=message country, $.user.id AS user_id
A path is a key (country), a dotted path ($.user.id, and the $. is
optional), or an array index. Brackets are query syntax, so a path using them
needs quoting:
| json field=message "items[0].sku" AS first_sku
A nested object becomes one column per leaf, named with dots - cart.items
for {"cart":{"items":3}}. An array stays whole, as the JSON text that was
there, until you index into it.
Numbers
A value's type comes from the data, so a key that holds numbers can be compared and averaged as one:
| json field=message | where duration_ms > 500
When a key holds numbers in some events and text in others, it is read as text, because reading it as a number would turn those other events into blanks. Say which you want with a suffix, and the data no longer decides:
| json field=message duration_ms:number, order_id:string
:raw is the third, and gives you a nested object or array as its JSON text.
input= is an accepted spelling of field=, so a search carried over from
Splunk needs only the stage name changed.
json or extract
Both pull new fields out of one field for the duration of a query, and
neither changes what is stored. Use json when the content is JSON, and
extract when it is not. A regex over JSON works right up until the key
order changes, a space appears after a colon, or a value stops being quoted.
Time range
Every query runs against an explicit time range, passed alongside the query
string rather than embedded in it - the Explorer's time-range picker sets
this, and the same from/to pair is what POST /v1/query takes (see the
API reference).
What's next
The generated reference lists every stage ObiQL
supports - it's generated directly from the stage registry the parser
itself reads, so it can never describe a stage that doesn't actually work.
Each stage links to a page of its own with the full syntax, every argument
and function, and worked examples - start with
stats or eval.