What You Can Query
| Table | Contains |
|---|---|
| spans | Individual spans (LLM/tool/custom/eval spans) |
| traces | Trace-level aggregates derived from spans |
| events | Custom events you’ve sent |
| tags | Tags attached to spans |
| dataset_datapoints | Dataset datapoints (latest version per datapoint) |
| dataset_datapoint_versions | Dataset datapoints (all versions/history) |
| evaluation_datapoints | Evaluation datapoints incl. scores (JSON map) + executor output |
SELECT queries are allowed.
Getting Started
Open the SQL Editor from the sidebar. Write a query:/v1/sql/query—authenticate with your project API key and pass { "query": "..." }.
Writing Queries
Laminar uses ClickHouse, a columnar analytics database. The basics work like standard SQL (SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT), with a few differences.
Always filter by time
Spans are ordered bystart_time. Adding a time filter dramatically speeds up queries and prevents memory issues:
Avoid joins
ClickHouse isn’t optimized for joins. Instead, run two queries and combine results in your application:Working with dates
Truncate timestamps for grouping withtoStartOfInterval:
INTERVAL 15 MINUTE, INTERVAL 1 HOUR, etc.
Shortcuts exist for common intervals: toStartOfDay(value), toStartOfHour(value), toStartOfWeek(value).
Working with JSON
Many columns (likeattributes) store JSON as strings. Use simpleJSONExtract* functions for fast extraction:
simpleJSONHas:
JSONExtract* functions—more flexible but slower.
Data types
| Type | Used for |
|---|---|
UUID | Most ID columns (trace_id, span_id) |
DateTime64 | Timestamps (always UTC) |
String | Text, including JSON stored as strings |
Float64 | Floating point numbers |
UInt64 | Counts, token numbers |
UInt8 | Enum values (like span_type) |
'value'::Type syntax: '2025-01-01'::DateTime
Example Queries
Cost breakdown by model:Exporting Results
Select results and click “Export to Dataset.” Map columns to dataset fields (data, target, metadata). Use this to build evaluation datasets from query results.
