원클릭으로
query-clickhouse
Query ClickHouse observability logs over HTTP API
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Query ClickHouse observability logs over HTTP API
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Debug issues using E2E tests, log analysis, and dev server management
Iterate on bug hypotheses using Playwright repro scripts, structured logs, and source code analysis
Address unresolved inline diff comments and mark them resolved
Run a long task across multiple agent contexts using breadcrumb progress files
Recursively decompose a task into sub-plans with dependency ordering, then execute in topological waves
Orchestrate multiple agents programmatically using anvil-repl
| name | Query ClickHouse |
| description | Query ClickHouse observability logs over HTTP API |
| argument-hint | [SQL query or investigation description] |
| user-invocable | true |
| allowed-tools | Bash |
Query anvil production logs stored in ClickHouse via HTTP API using curl.
Credentials are in server/.env (gitignored). Before every curl command, source the env file to load connection variables:
source server/.env && curl -s --user "$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD" \
"$CLICKHOUSE_URL/" \
--data "SELECT ... FORMAT JSON"
The env file provides: CLICKHOUSE_URL, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_DATABASE, CLICKHOUSE_TABLE.
FORMAT JSON for structured outputFORMAT JSONCompact for large result sets (less verbose)logs — Core log events (~1.8M rows)| Column | Type | Description |
|---|---|---|
log_id | String | UUID, auto-generated, primary key |
timestamp | DateTime64(3) | Event time with ms precision |
device_id | String | Device identifier (defaults to '') |
level | LowCardinality(String) | debug, info, warn, error |
message | String | Event message |
log_properties — Key-value properties per log| Column | Type | Description |
|---|---|---|
log_id | String | FK to logs.log_id |
device_id | String | Device identifier |
timestamp | DateTime64(3) | Event timestamp (duplicated for ordering) |
key | LowCardinality(String) | Property name |
value_string | String | String value (default '') |
value_number | Float64 | Numeric value (default 0) |
value_bool | UInt8 | Boolean value (default 0) |
identities — Device-to-user mapping| Column | Type | Description |
|---|---|---|
device_id | String | Device identifier |
github_handle | String | GitHub username |
registered_at | DateTime64(3) | Registration timestamp |
Common keys in log_properties (88 total). Notable ones:
thread_id, agent_id, device_id, terminal_id, watch_id, parent_idcommand, cwd, pid, exit_code, duration_ms, elapsed_mserror, result, successstdout, stdout_len, stderr_len, bytes, read.bytes, szwindow, focused, hotkey, shortcut, width, height, colsconn, connection.state, socket_path, socket_health, stream.idpath, runner, event, kind, stage, pipeline, shell, programadditional, properties, raw_contents, previewAll queries below assume source server/.env has been run first.
# Template for all queries:
source server/.env && curl -s --user "$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD" \
"$CLICKHOUSE_URL/" --data "YOUR_QUERY FORMAT JSON"
-- Recent errors
SELECT timestamp, level, message FROM logs
WHERE level = 'error' ORDER BY timestamp DESC LIMIT 50
-- Logs with a specific property (e.g., thread_id)
SELECT l.timestamp, l.level, l.message, p.value_string AS thread_id
FROM logs l
JOIN log_properties p ON l.log_id = p.log_id
WHERE p.key = 'thread_id' AND p.value_string = '...'
ORDER BY l.timestamp
-- Search by message
SELECT timestamp, level, message FROM logs
WHERE message ILIKE '%pattern%' ORDER BY timestamp DESC LIMIT 100
-- Error rate by hour
SELECT toStartOfHour(timestamp) AS hour, count() AS errors
FROM logs WHERE level = 'error'
GROUP BY hour ORDER BY hour DESC LIMIT 24
-- Level distribution
SELECT level, count() AS total FROM logs GROUP BY level ORDER BY total DESC
-- Get all properties for a specific log
SELECT key, value_string, value_number, value_bool
FROM log_properties WHERE log_id = '...'
-- Logs with errors (property-based)
SELECT l.timestamp, l.message, p.value_string AS error
FROM logs l
JOIN log_properties p ON l.log_id = p.log_id
WHERE p.key = 'error' AND p.value_string != ''
ORDER BY l.timestamp DESC LIMIT 50
-- Duration outliers
SELECT l.timestamp, l.message, p.value_number AS duration_ms
FROM logs l
JOIN log_properties p ON l.log_id = p.log_id
WHERE p.key = 'duration_ms' AND p.value_number > 1000
ORDER BY p.value_number DESC LIMIT 50
-- Device activity summary
SELECT device_id, count() AS events, min(timestamp) AS first, max(timestamp) AS last
FROM logs GROUP BY device_id ORDER BY events DESC LIMIT 20
-- Resolve device to GitHub user
SELECT d.device_id, i.github_handle, count() AS events
FROM logs d
LEFT JOIN identities i ON d.device_id = i.device_id
GROUP BY d.device_id, i.github_handle
ORDER BY events DESC
-- Multiple properties for same log (pivot pattern)
SELECT
l.timestamp, l.message,
maxIf(p.value_string, p.key = 'thread_id') AS thread_id,
maxIf(p.value_string, p.key = 'command') AS command,
maxIf(p.value_number, p.key = 'duration_ms') AS duration_ms
FROM logs l
JOIN log_properties p ON l.log_id = p.log_id
GROUP BY l.log_id, l.timestamp, l.message
ORDER BY l.timestamp DESC LIMIT 50
When given a vague request like "check for errors" or "why is it slow":
log_properties to get thread_id, agent_id, command, etc.thread_id or device_id to follow a session across eventsidentities to map device_id to github_handleThe JSON response contains:
data — array of result rowsrows — total row countstatistics.elapsed — query execution time in secondsmeta — column type informationParse and summarize results for the user rather than dumping raw JSON.