Browse docs
On this page

ObiQL Tutorial

A worked example, from a bare search to a chart-ready aggregation.

This walks one query from the simplest possible form to something you could bind a dashboard panel to, using the same sample data as the rest of these docs: a checkout-api service occasionally timing out against a payment gateway.

1. Start broad

timeout

A bare term matches anywhere in the event - message, any string field. Useful for a first pass when you don't yet know which field holds what you're looking for.

2. Narrow with field filters

service="checkout-api" level="error"

Multiple filters are ANDed together. Field names come from what your workspace has actually ingested - see Field discovery for how the query bar knows what fields exist without you defining a schema anywhere.

3. Aggregate with stats

service="checkout-api" level="error" | stats count() by service

| stats turns matching raw events into an aggregation - here, a count grouped by service. See stats in the reference for every aggregation function it supports.

4. Bucket over time

service="checkout-api" level="error" | timechart span=5m count() by service

Swap stats for timechart and you get the same aggregation bucketed into fixed time windows - the shape a dashboard panel binds to directly. See timechart in the reference.

5. Sort and cap the result

service="checkout-api" level="error" | timechart span=5m count() by service | sort -count | limit 20

Chain as many stages as you need; each one operates on the output of the one before it. then is accepted in place of | throughout, so the same query can be written as prose if you prefer it:

service="checkout-api" level="error" then timechart span=5m count() by service then limit 20

What's next

The generated reference documents every stage this walkthrough used, and every one it didn't.