ClickHouse analytics DB
v0.2.15ClickHouse server + table introspection — metrics, errors, slow & failed queries, parts/partitions, merges, mutations, replication queue, Keeper/ZK health, detached parts, distributed-send backlog, backups — plus narrow mutators (OPTIMIZE, KILL QUERY, SYSTEM RELOAD CONFIG, replica ops). Auth via CH_HOST + CH_USER + CH_PASSWORD env vars on the runner host. Uses clickhouse-client with --query to keep arg surface minimal.
clickhouse-client
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below — the exact bytes this page was rendered against, so a tampered copy is
rejected — before copying it into the runner's packs dir. The command reloads a
running daemon itself; no manual restart.
sudo emisar pack install clickhouse --hash sha256:99df7cbb45e67ca8649f4f69a184ce02944e4f332cdb2695fffaf5360484284b
Setup
Each action reads
CH_HOST
,
CH_USER
, and
CH_PASSWORD
on the runner host and passes host/user to clickhouse-client as --host/--user; the password is handed over via the client's native CLICKHOUSE_PASSWORD env var so it never lands on the process command line. Host and user fall back to localhost and the default user, so a local server with the default account needs no setup at all.
Environment
Set these on the runner host, then add each name to
execution.inherit_env
so the value reaches the action.
-
CH_HOSTdefault localhostServer host passed to --host.
-
CH_USERdefault defaultUser passed to --user.
-
CH_PASSWORDPassword handed to clickhouse-client via CLICKHOUSE_PASSWORD (kept off argv). Leave unset for a passwordless account.
Notes
-
Any of
CH_HOST/CH_USER/CH_PASSWORDyou set must also be allowlisted in the runner'sexecution.inherit_env— the action env is scrubbed to PATH/LANG/LC_ALL/TERM by default, so an env present on the host but not allowlisted is silently dropped (the action falls back to its local default or fails auth). - Connection always uses clickhouse-client's default native port (9000); there is no port env var in this pack.
- The user needs SELECT on the system tables for the reads, plus rights for the mutators (KILL QUERY, OPTIMIZE, SYSTEM ... for replica/config actions) you enable.
- The replication/Keeper reads (replication_queue, zookeeper_connection, keeper_status, detached_parts) only return data on a ReplicatedMergeTree + Keeper/ZooKeeper deployment; on a single non-replicated server they come back empty, which is correct, not an error.
Verify it works
Runs ch.uptime, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify clickhouse
Install and configure a pack walks through the whole sequence on a host.
Actions 32 total
View on GitHub-
ch.asynchronous_metrics exec low Low — read-only or trivially reversible
SELECT * FROM system.asynchronous_metrics
Show periodically-computed metrics — replica lag (ReplicasMaxAbsoluteDelay), max parts per partition, filesystem and memory. The async counterpart to system.metrics.
View source on GitHub -
ch.backups exec low Low — read-only or trivially reversible
SELECT * FROM system.backups
List BACKUP/RESTORE operations since the last server start with status and error. Non-persistent across restarts.
View source on GitHub -
ch.detached_parts exec low Low — read-only or trivially reversible
SELECT * FROM system.detached_parts
List parts ClickHouse detached and will not auto-attach (corruption, manual detach, broken), each with a reason. Empty is healthy.
View source on GitHub -
ch.dictionaries exec low Low — read-only or trivially reversible
SELECT * FROM system.dictionaries
List loaded dictionaries with status, element count, source.
View source on GitHub -
ch.disks exec low Low — read-only or trivially reversible
SELECT * FROM system.disks
List configured disks with free/used bytes + paths.
View source on GitHub -
ch.distribution_queue exec low Low — read-only or trivially reversible
SELECT * FROM system.distribution_queue
Show distributed-table async send backlog — pending files, errors, blocked sends. Spot a Distributed table not flushing to shards.
View source on GitHub -
ch.errors exec low Low — read-only or trivially reversible
SELECT * FROM system.errors
List error codes seen since startup with counts and the last message. Spot error storms.
View source on GitHub -
ch.keeper_status exec low Low — read-only or trivially reversible
List a Keeper/ZooKeeper path (system.zookeeper)
List child nodes and metadata under a Keeper/ZooKeeper path. system.zookeeper requires a path filter, so the path arg is mandatory.
View source on GitHub -
ch.kill_mutation exec critical Critical — data loss or irreversible
Cancel a stuck mutation (KILL MUTATION)
Cancel one ClickHouse mutation by its (database, table, mutation_id) — KILL MUTATION WHERE …. Use to stop a mutation wedged on a failure (see ch.stuck_mutations) so the table's merges and inserts can proceed. Destructive — the mutation is abandoned mid-flight — so risk:critical → default-denied. An operator allows it by explicit policy, and WHICH mutations are permitted is a portal policy decision.
View source on GitHub -
ch.kill_query exec high High — service-affecting
KILL QUERY WHERE query_id = '<id>'
Cancel one running query by ID.
View source on GitHub -
ch.merge_queue exec low Low — read-only or trivially reversible
SELECT * FROM system.merges
List in-progress + queued merges.
View source on GitHub -
ch.mutation_queue exec low Low — read-only or trivially reversible
SELECT * FROM system.mutations
List in-progress + pending mutations (ALTER TABLE).
View source on GitHub -
ch.optimize_table exec high High — service-affecting
OPTIMIZE TABLE FINAL
Force merge of all parts into one. Heavy disk + CPU.
View source on GitHub -
ch.parts_by_partition exec low Low — read-only or trivially reversible
Active part count per partition (system.parts)
List active parts grouped by partition, top offenders first. Where you actually diagnose too-many-parts / merge backlog (parts_summary is table-level only).
View source on GitHub -
ch.parts_summary exec low Low — read-only or trivially reversible
SELECT system.parts (by table)
List active part counts + sizes per table. Use to spot too-many-parts.
View source on GitHub -
ch.processes exec medium Medium — changes state, easily reversible
SELECT * FROM system.processes
List currently-running queries. Rated medium because the output carries live query text, which can include literal request values no redaction list can enumerate.
View source on GitHub -
ch.query_errors exec medium Medium — changes state, easily reversible
Failed queries from system.query_log (last hour)
List queries that failed in the last hour (exception types 3 and 4) with code, message, and query. The error counterpart to slow_queries. Rated medium because the output carries live query text and exception messages, which can include literal request values no redaction list can enumerate.
View source on GitHub -
ch.reload_config exec high High — service-affecting
SYSTEM RELOAD CONFIG
Re-read config.xml + users.xml without restarting; whatever is now on disk — including changed users and access grants — takes effect on the live server immediately.
View source on GitHub -
ch.replicas_status exec low Low — read-only or trivially reversible
SELECT * FROM system.replicas
Show per-replica state — leader, queue size, log delays, errors.
View source on GitHub -
ch.replication_queue exec low Low — read-only or trivially reversible
SELECT * FROM system.replication_queue
Show per-task replication queue — retries, postpones, last exception. Spot stuck fetches/merges (distinct from per-replica state).
View source on GitHub -
ch.slow_queries exec medium Medium — changes state, easily reversible
system.query_log slowest queries
List top 50 slowest queries from the last hour. Rated medium because the output carries live query text, which can include literal request values no redaction list can enumerate.
View source on GitHub -
ch.stuck_mutations exec low Low — read-only or trivially reversible
Failing mutations (system.mutations)
List mutations stuck on a failure (latest_fail_reason set), with the failed part and reason. Narrower than the full mutation queue — surfaces only what is actively failing.
View source on GitHub -
ch.system_drop_replica exec critical Critical — data loss or irreversible
SYSTEM DROP REPLICA <name>
Remove a replica's metadata from ZooKeeper for one table. Use only for an already-dead replica that is never coming back. The replica cannot rejoin without recreating its tables. Wrong replica name destroys a healthy cluster member's metadata.
View source on GitHub -
ch.system_events exec low Low — read-only or trivially reversible
SELECT * FROM system.events
List process-lifetime event counters.
View source on GitHub -
ch.system_flush_logs exec medium Medium — changes state, easily reversible
SYSTEM FLUSH LOGS
Force write buffered system.*log tables to disk. Use before querying very recent activity from query_log, part_log, etc.
View source on GitHub -
ch.system_metrics exec low Low — read-only or trivially reversible
SELECT * FROM system.metrics
Show per-metric current values (gauges + counters).
View source on GitHub -
ch.system_restart_replica exec high High — service-affecting
SYSTEM RESTART REPLICA <table>
Reinitialize the local replication state for one table. Useful when the replica is stuck or its ZooKeeper state diverged. Heavy — may re-fetch many parts.
View source on GitHub -
ch.system_sync_replica exec medium Medium — changes state, easily reversible
SYSTEM SYNC REPLICA <table>
Wait for the local replica to catch up with all peers. Returns when in sync. Use to confirm replication caught up before doing reads from this replica.
View source on GitHub -
ch.table_sizes exec low Low — read-only or trivially reversible
system.tables uncompressed sizes
List top 50 tables by uncompressed size.
View source on GitHub -
ch.tables_overview exec low Low — read-only or trivially reversible
Engine inventory (system.tables)
List all non-system tables with engine, row/byte totals, and part counts. Engine inventory + fleet shape.
View source on GitHub -
ch.uptime exec low Low — read-only or trivially reversible
SELECT version, uptime
Show server version + uptime.
View source on GitHub -
ch.zookeeper_connection exec low Low — read-only or trivially reversible
SELECT * FROM system.zookeeper_connection
List active Keeper/ZooKeeper connections — host, session age, expiry, API version. Empty on a non-replicated single node.
View source on GitHub