Execute a SQL query against the organization's ClickHouse data.
POST /clickhouse/sql-queries/
{
"query": "SELECT model, count(*) as cnt FROM logs GROUP BY model ORDER BY cnt DESC",
"parameters": {} // reserved for future ClickHouse parameterized query support
}
Returns:
{
"columns": ["model", "cnt"],
"rows": [["gpt-4", 150], ["claude-3", 120], ...],
"row_count": 25,
"execution_time_ms": 342
}
Request
This endpoint expects an object.
querystringRequired1-10000 characters
ClickHouse SQL query. Only SELECT statements allowed.
start_timedatetimeOptional
Optional. Bound into {{ start_time }} references.
end_timedatetimeOptional
Optional. Bound into {{ end_time }} references. Must be after start_time when both are set.
environmentenumOptional
Optional environment filter; non-all is injected into the rewritten SQL as an equality filter on environment.
all - all
prod - prod
test - test
filtersmap from strings to anyOptional
Optional dashboard filters for saved SQL queries that opt in.
dashboard_filteringobjectOptional
Optional dashboard filter context for saved SQL execution.
Response
columnslist of strings
Column names in the result set.
rowslist of lists of any
Result rows (each row is an array of values).
row_countinteger
Number of rows returned.
execution_time_msinteger
Server-side query execution time in milliseconds.
warningslist of maps from strings to any
Non-fatal dashboard filter warnings.