Query log and Errors drill-down
Faceted browser over system.query_log with attribution resolved to the bi-api caller. Row-detail drawer with SQL, exception, and metrics; keyboard navigation; deep-link; per-error drill-down from the counters feed.
The query log is a faceted browser over ClickHouse’s own system.query_log, enriched with the tenant-side attribution bi-api stamps on every query it runs. For now it covers only queries run on Goni Cloud: it reads Goni’s own server, so a workspace with its own ClickHouse attached sees none of its queries here. Its sibling Errors tab merges a last-hour exception feed with the all-time system.errors counter table. Both are backed by the same admin-gated endpoints as the Pulse page.
You’ll learn:
- What the two tabs show and where each column comes from
- How the row-detail drawer works, and which keys navigate it
- How to share a permalink to a single query, and how the counter drill-down chains into a filtered log view
- How long attribution is retained, and what happens when a row predates the attribution splice
What it is
Every query bi-api runs on the caller’s warehouse is stamped with a JSON log_comment carrying {tenant_id, user, request_id, artifact_kind, artifact_id}. ClickHouse records that on the query, and the query-log endpoint parses it back out on the way to the SPA. So a row that arrived at the cluster as user goni (the CH-side service account) renders on the page as alice@paysera.net - chart:mrr_by_month - the person and the artifact that actually triggered the read.
Rows written before the attribution splice landed - and rows from tools that connect directly to the cluster (psql, clickhouse-client, DBeaver) - fall back to initial_user as the resolved user so they still render with a name. The row’s resolved_source field records where the attribution came from (log_comment, initial_user, or empty), so the UI can render a small icon differentiating rich rows from legacy ones.
URL and access
The page lives at /ops/queries/log. Same admin gate as the rest of the operational tier: every endpoint behind the page checks AllowAdminPolicies and returns 403 when it is not set. See Access control.
Two tabs
Query log. A paginated table over system.query_log for the caller’s tenant, filtered to type IN ('QueryFinish', 'ExceptionWhileProcessing', 'ExceptionBeforeStart') so the row list is one entry per real user query (no partial QueryStart duplicates). A time-window picker at the top of the table snaps to 1h / 6h / 24h / 3d / 7d; the default is 24h. A search box narrows by query text, user, or query_id. Facet chips filter by event type. Pagination is offset-based with a total-count sidecar so the SPA can render numbered page controls up to a few thousand rows; beyond that the UI nudges you to narrow the window.
The endpoint accepts these query-string parameters (all bounded server-side):
GET /api/ops/queries/log?hours=24&limit=50&offset=0&code=0
Columns on the wire: event_time, query_id, user, initial_user, type, query_kind, query_duration_ms, read_rows, read_bytes, memory_usage, exception_code, a 500-char exception_preview, a 500-char query_preview, the raw log_comment, plus the promoted resolved_tenant_id / resolved_user / resolved_request_id / resolved_artifact_kind / resolved_artifact_id / resolved_source fields.
Errors. Two feeds side-by-side.
- The last-hour exceptions feed reads
system.query_logwheretype IN ('ExceptionWhileProcessing', 'ExceptionBeforeStart')andexception != '', ordered byevent_time DESC, capped at 100 rows. Each row is attribution-enriched so the exception is pinned to a user and an artifact. - The all-time counters feed reads
system.errors- ClickHouse’s cumulative counter of every error kind the server has ever raised - ordered byvalue DESC, capped at 100 rows. Each row carriesname(e.g.SYNTAX_ERROR),code, cumulativevalue, plus thelast_error_timeof the most recent occurrence and thenode. The table has no owner per row, so on a deployment with workspaces these counters cover the whole server andlast_error_messagestays empty.
Both feeds are served together by GET /api/ops/errors and either can fail without blanking the other.
The row detail drawer
Click any row on the Query log tab or any row in the last-hour exceptions feed on the Errors tab and a right-side drawer slides in. It carries:
- The full SQL, opened in a word-wrapped Monaco editor with syntax highlighting. No truncation - the 500-char previews on the row are just for the table view; the drawer pulls the full body.
- The full exception body when the row is an exception.
- Four metrics tiles: duration, rows read, bytes read, peak memory usage.
- The resolved attribution block: user, artifact kind and id, request id, tenant id.
The drawer is served by GET /api/ops/queries/detail/{query_id} and reads the single row directly from system.query_log.
Keyboard
jorArrowDown- open the next row down.korArrowUp- open the previous row up.Esc- close the drawer.
The list keeps its scroll position while stepping through rows, so a walk through the last-hour exceptions feed feels like flipping through a stack of index cards.
Deep-link
The drawer writes its currently-open row into the URL as ?open=<query_id>. Loading the page with that parameter opens the drawer to that row on the first render, so a link pasted into a Slack thread lands the reader on exactly the query being discussed. Bookmark-friendly and history-friendly - the browser Back button walks the drawer selection.
Counter drill-down
Every row in the all-time counters feed is clickable. Clicking SYNTAX_ERROR - 87 navigates to the Query log tab with ?code=62 in the URL (the numeric error code for SYNTAX_ERROR), and the table narrows to rows whose exception_code matches. A removable red chip above the table shows the active filter; clicking the chip clears it back to the full log. This is the “grouped by error” drill-down: pick a common failure from the counter feed, drop into the individual query events that produced it.
The endpoint enforces the filter server-side. The count query runs alongside the page query so numbered page controls still work under the filter.
Footer actions on the drawer
Three buttons along the drawer footer, all inert until the row is loaded:
- Copy to IDE. Opens the SQL IDE at
/ide?sql=<encoded>with the full query loaded, ready to edit and re-run against the same warehouse. - Diagnose. Opens the Doctor RCA agent at
/ops/doctor?query_id=<id>with the target query pinned. Available on any row, but the button is most useful on a runaway or an exception. - Close. Same as pressing
Esc.
Retention
- Attribution. The
log_commentsplice is stamped inline on the query and lives for as long as ClickHouse keeps the query insystem.query_log. Goni also keeps it in its control-plane database for 90 days, so the resolved attribution outlives an aggressivesystem.query_logretention policy. system.query_log. Retention is under your warehouse’s own retention policy. The Errors feed and the query-log page both read directly from that table, so shortening its TTL shortens the window Goni can show.system.errors. Cumulative from server start. It resets on ClickHouse restart, so a fresh cluster looks empty until real usage lands.
Related
- Pulse: live cluster vitals - the live board this page pairs with
- Doctor RCA agent - what the “Diagnose” button opens
- SQL IDE - where “Copy to IDE” opens the full query
- Access control - the admin permission that gates every
/api/ops/*endpoint
Last updated