Filter from the UI
Select Filter to open the filter menu with quick filters for common fields like tags, time range, and comments. Use the Basic tab for point-and-click filtering, or switch to SQL to write precise queries. The SQL editor includes a Generate button that creates queries from natural language descriptions. Some examples of what you can express in the SQL filter:=, !=, >, <, >=, <=), logical operators (AND/and, OR/or, NOT/not), and functions like INCLUDES/includes for array membership.
SQL queries on project logs enforce your plan’s data retention limit. Use a relative interval to stay within the window. See Plans and limits for retention details.
When filtering traces by both tags and scores, use
ANY_SPAN() to match traces where different spans contain different attributes. For example, ANY_SPAN(tags INCLUDES "production") AND ANY_SPAN(scores.Factuality IS NOT NULL) finds traces where any span has the tag and any span has the score. See Analyze based on tags and scores for examples.Ask questions with Loop
Select Loop on the Logs page to ask natural language questions about your traces. Loop understands your data structure and can answer questions, identify patterns, and surface specific traces without writing any queries. Example questions:- “Show me traces where the user was confused”
- “Find requests that took longer than usual”
- “What are the most common error patterns?”
Find traces with deep search
Deep search finds traces based on semantic similarity rather than keyword matching or exact filters. It’s useful for discovering patterns, sentiment, and edge cases that SQL filters would miss. For example, you can find traces where users expressed frustration, even if the word “frustrated” never appears. See Use deep search for detailed examples and workflows.Query via the CLI
Thebt CLI gives you two ways to work with logs from the terminal.
bt view logsis an interactive terminal UI, good for browsing and spot-checking during development or an on-call incident without opening a browser.bt sqlis for when you need more power: run arbitrary SQL queries, pipe results into other tools, or integrate log queries into scripts and CI pipelines.
Browse logs
Usebt view logs to open a live, scrollable view of your project’s logs. You can narrow the results with a search term, a filter expression, or a time window, all without leaving the terminal.
Run SQL queries
Usebt sql to run full SQL queries against your logs. Pass a query inline or pipe one in from a file.
--non-interactive to skip the interactive interface and --json to get machine-readable output.
Download logs locally
Usebt sync pull to download logs to local NDJSON files for offline analysis, backup, or migration.
bt sync for the full flag reference.
Query via the API
Query logs programmatically using the Braintrust API for automation, integrations, and custom tooling.Basic filtering
Use the project logs endpoint for simple filters and programmatic access:Advanced SQL queries
For complex queries, use the Braintrust API:query(required): Your BTQL query stringfmt: Response format (jsonorparquet, defaults tojson)tz_offset: Timezone offset in minutes for correct day boundariesaudit_log: Include audit log data
Speed up log filtering
If you frequently filter on the same custom fields, you can index them to reduce query latency. Braintrust offers two options: A full-text index for broad search and subfield indexes for specific fields you filter on most.- Go to Settings > Project > Advanced.
- Under Log search optimization, enable the toggle to build a full-text index that speeds up text-based filter queries.
-
Under Subfield indexing, click + Add subfield index for each field you filter on frequently.
Braintrust auto-discovers candidate fields from your data (e.g.,
metadata.session_id). If a field doesn’t appear, you can type it in directly. Subfield paths must start withinput,output,expected,metadata, orspan_attributes. - Click Save and index.
- Enter how many days back to backfill (default: 3) and click Save and backfill.
Next steps
- Use deep search for semantic queries
- Score online to evaluate filtered traces
- Create dashboards with filtered metrics
- Read the SQL reference for complete query syntax