Query with the CLI
Pass a query as one quoted argument, or use--file <path> to read it from a file:
--csv for CSV, --json for the complete API response, and --output <file> to write the selected format to a file.
{name:Type} placeholders with one --param name=value flag per value. Parameters stay separate from the SQL text.
traceroot sql schema to list the available tables, columns, and ClickHouse types. The CLI repository documents installation, authentication, output formats, and the complete flag reference.
Worked queries
Always include a time predicate onspan_start_time or trace_start_time. The gateway uses that range when reading the underlying project-scoped views, so bounded queries scan less data.
Recent error spans
p95 latency by model
Cost by model over seven days
Query with the API
Send a project API key as a bearer token toPOST /api/v1/public/sql. A user session token also works with the project_id query parameter, which is how browser-login users run traceroot sql --project <id> without a project API key:
statistics is best-effort and may be empty. When more rows match than the gateway returns, truncated is true. A request’s max_rows can lower the server cap, but cannot raise it.
Fetch the same schema used by the validator and query rewriter with GET /api/v1/public/sql/schema:
Public schema
Queries can reference only two logical tables:
Use
traceroot sql schema --json or GET /api/v1/public/sql/schema for the authoritative column list and types.
These are curated views over TraceRoot’s internal tables. They deliberately exclude:
- span and trace
inputandoutputpayloads; - the raw metadata JSON document;
metadatais exposed instead as a one-level string map, accessed with expressions such asmetadata['user_id']; project_id,ch_create_time,ch_update_time, and internal classification fields;- rows that are not customer traffic; and
- every trace that belongs to an evaluation run, including its spans.
SQL contract
The gateway accepts oneSELECT or UNION. CTEs, subqueries, joins, grouping, ordering, and the row_number, rank, and dense_rank window functions are supported. Functions are allowlisted; the list includes common aggregation, date-bucketing, string, conversion, conditional, and metadata-map functions. A ClickHouse function outside the allowlist is rejected even if ClickHouse normally supports it.
The gateway rejects:
- multiple statements, writes, DDL, and control statements;
- tables other than
spansandtraces, including table functions; - database-qualified names and the internal view names;
FINAL,SETTINGS, andFORMATclauses;- any reference or alias named
project_id; - a CTE named
spansortraces; and - parameter names
project_idor beginning withscope_, which are reserved for server-side scoping.
Execution and rate limits
Default execution limits are:
The gateway reserves a row beyond the returned result to detect truncation. If that row exists, it removes the sentinel and returns
truncated: true. Queries that exceed the time, result-size, or memory limits fail; narrow the selected columns or time range and retry.
On self-hosted deployments, operators can change the four ClickHouse caps with CLICKHOUSE_SQL_MAX_EXECUTION_TIME, CLICKHOUSE_SQL_MAX_RESULT_ROWS, CLICKHOUSE_SQL_MAX_RESULT_BYTES, and CLICKHOUSE_SQL_MAX_MEMORY_USAGE.
Concurrency is not a queue. If either per-process slot limit is full, the API returns HTTP 429 with Too many queries are running. Retry shortly. and a one-second Retry-After header.
TraceRoot Cloud also applies a per-project SQL request rate:
SQL rate limiting is disabled on self-hosted deployments where billing is disabled.

