Skip to content

Search and live tail

How search, facets, histograms and live tail read recent and archived events.

Updated

Search and its aggregations answer questions about the past and order events by event time. Live tail follows what is arriving now, in ingestion order.

Search over hot and archived events

An index keeps recent events in DuckDB and older events in Parquet files, and you don’t choose between them. A query names an index and a time range, and Logbrook reads both stores in one consistent snapshot:

  1. It looks up the archive files whose recorded time range overlaps your range.
  2. It combines the hot rows with those Parquet files as a single dataset.
  3. It applies your filters and returns the matching events.

A query sees a stable set of events while ingestion, archival and compaction continue. Archive files that a running query reads stay on disk until it finishes.

Time ranges

Search, count, facets and histogram require from and to in Unix milliseconds. The range is UTC, includes from and excludes to. By default it can span at most 31 days (max_query_range_ms, up to 366 days). Ranges use event time, so a late event appears where its timestamp puts it.

Filters

There is no query language. You filter by source, service, logger, host, a case-sensitive message substring, a minimum level, and exact matches on top-level attributes. See search and filter and attribute filters for the syntax.

Read token scopes apply before your filters, so a source-scoped token never sees events outside its sources.

Results and pages

Search returns events newest first by event time, with the event ID as tiebreaker. A page holds at most max_page_size events, 1,000 by default. When more events match, the response includes a next_cursor. Send it back with the same range and filters to get the next page.

Cursors are bound to their query

A cursor is an opaque token that records:

  • the index (on named-index routes, the token is prefixed with the index name)
  • a SHA-256 fingerprint of the range, page size, sources, filters and ordering
  • the position where the previous page ended
  • the highest event ID that existed when the first page ran

Logbrook accepts a cursor only for the same query. Change a filter, the range or the index, and the cursor is rejected. The fingerprint prevents mistakes, not tampering, so don’t treat cursors as a security feature. Pinning to the highest event ID keeps paging stable: events ingested after the first page don’t shift later pages.

If retention removes the history a cursor points into, the next request fails with 400 and you start the search again.

Facets, counts and histograms

These read the same dataset with the same filters. A count returns the number of matches, facets return the distinct values of service, logger, host, level and source with their counts, and a histogram groups matches into time buckets by event time. See counts, facets and histograms.

Live tail

Live tail streams new events over server-sent events, in ingestion order.

Ordering

Tail delivers events in the order Logbrook committed them. A delayed event with an old timestamp shows up when it arrives, after events with later timestamps. Commit order gives tail a stable position to resume from, even when producers have skewed clocks.

Starting and resuming

A new stream starts after the newest committed event and doesn’t replay history. Each event carries an SSE id. A client that reconnects with that ID in a Last-Event-ID header first receives the retained events it missed, then new ones. When the stream has caught up, it sends a cursor event with the data caught up.

Tail takes the same field filters as search, under the same source and index scopes. Like a search cursor, a resume ID is bound to the stream’s filters, so reconnect with the filters you started with.

Gap notices

Tail can’t resume across events that no longer exist. If retention expires events the stream hasn’t sent yet, or a subscriber’s output buffer is exceeded (max_tail_buffer_bytes), the stream ends with a gap event. Search the period you may have missed, then reconnect.

Any other failure ends the stream with an error event.

A slow client only slows its own stream: each subscriber has its own buffer, and at most max_tail_subscribers (8 by default) can connect. See live tail for how to consume the stream.

Next steps

Type to search…

↑↓ navigate↵ selectEsc close