Skip to main content
bronto search runs one query and exits. The query is a Bronto WHERE expression, the same language the web app’s search bar uses. The search syntax page on docs.bronto.io documents it in full. Under the hood, bronto search calls the search API.

Narrowing 502s in checkout-service

The basics

  • Dataset. -d/--dataset takes a dataset name or UUID and can be repeated to search several at once. Qualify a name that exists in more than one collection as collection/name. Without -d, the CLI uses default_dataset from your config, or the only dataset if the account has just one. Otherwise it fails with usage_missing_dataset and lists the datasets it found. --from-expr takes a dataset selector expression instead, for example --from-expr "log_id = '<uuid>'".
  • Time range. --since takes a relative lookback such as 30s, 15m, 1h, 2d, 1w, or 1h30m. For a fixed window, pass RFC 3339 timestamps with --from and --to. With no time flag, the search covers the last 15 minutes.
  • Size and order. -n/--limit caps the number of events (1 to 10000, default 100). Results come newest first. --oldest-first flips that, and --order-by takes an SQL-style order such as 'duration_ms DESC'.
  • Stdin. Pass - as the query to read it from stdin, which helps with long queries and quoting.
At a terminal, the result is a table. The CLI ranks parsed fields by how often they hold a value and how much they vary, and turns the best ones into columns. Once it has three useful columns it drops the raw JSON. A footer on stderr points to bronto fields, --select, and -x.

Filter flags instead of WHERE

The filter flags build the WHERE expression for you:
Each flag can be repeated. The CLI ANDs them together, and with the positional query if you pass one. The CLI looks up each field name in the dataset’s field index, so model finds $model and matching is case-insensitive. It quotes the value based on its shape: numbers and booleans stay bare, strings get single quotes. The compiled filter is echoed to stderr.
  • --show-query prints the compiled WHERE and exits without searching.
  • --exact turns off the fuzzy name lookup and uses field names as written. Use it in scripts.
  • An unknown or ambiguous field name is an error (exit code 2) that lists candidates.

Look closer at events

-x/--expand is the β€œclick on a row” view. It prints every field of every event, one per line and untruncated, including the metadata.* fields the table hides.
-x only works with table output. When piped, add -o table. The JSON formats already carry every field. To see what happened around one event, use bronto context. It needs the event’s metadata.sequence value and its timestamp in Unix milliseconds, both visible in the -x view:
--direction is before, after, or both (the default), and -n sets how many events to fetch in each direction.

Find the right field names

bronto fields lists the fields seen in a dataset, each with a sample of values, so you can spell a query correctly the first time. Add a positional filter to keep only fields whose name contains it:
Leave out -d to scan all datasets. --since (default 1h) sets how far back to look and -n caps the number of fields. bronto query check validates an expression locally, without calling the API, and points a caret at the problem:
With -d <dataset> it also warns about fields that haven’t appeared in that dataset recently and suggests close matches. --strict turns those warnings into a failure for use in CI.

Aggregate

--select picks columns or aggregate functions, and -g/--group-by groups by one or more keys. Both are repeatable.
For timeseries aggregates, --slices sets the number of time buckets.

Summaries

Two flags summarize a result instead of listing events. --histogram shows when matching events happened, which answers β€œwhen did this start and how big is it?”:
All 13 errors land in the few buckets after 09:21. Empty buckets print 0, so a quiet period before a spike is easy to see. --patterns clusters events into message templates with counts, which shows what a noisy dataset is mostly made of (learn more about patterns):

Saved searches and the web UI

--saved <name> runs a saved search by name or id. Query, dataset, and time flags you pass on the command line override what’s stored.
Saved searches are a regular resource, so bronto saved-searches create, update, and delete manage them. --url prints a link to the same query in the Bronto web app, and --open opens it in your browser. Neither runs the query. The link targets your active org. If the CLI can’t work out the org, set it with bronto config set org_id <uuid>. --explain-only returns the query plan and cost estimate instead of results.

Search local files

--local <file> evaluates the query on your machine over an NDJSON or plain-text file. Nothing is sent to Bronto and no API key is needed, so it works on downloaded exports or a kubectl logs dump. Pass - to read stdin.
JSON lines are queryable by their keys (nested keys in dotted form). Plain-text lines are matched with @raw ~ 'regex'. -o, --fields, --jq, and -n work. Dataset, time range, select, and group-by flags don’t apply and are rejected.

The REPL

For a longer investigation, bronto repl opens a psql-style prompt. Type a WHERE expression to run it, then edit it and run it again.
History is saved in your config directory between sessions. The REPL needs a terminal. Piped, it exits with code 2. To go from a question in plain English to a query, see Ask.