All posts

5 min of ClickHouse: upgrade safely while chmonitor stays connected

Pre-upgrade checks, the system-table changes that light up new dashboard pages at each version, and the post-upgrade grants sanity queries — so you upgrade ClickHouse without losing monitoring.

Five minutes, one real runbook, no fluff. chmonitor stays connected through a ClickHouse upgrade — it uses versioned SQL (since per query config) to automatically pick the right query for the connected version. But a few pre/post checks keep the dashboard fully lit.

Before you upgrade

curl -s "https://your-ch-host:8443?query=SELECT+version()" -u monitoring:password

chmonitor supports 22.x+, with full coverage recommended from 23.8 LTS. Back up the settings you’ll compare afterward, and clear the backlog that blocks a clean replica upgrade:

-- Save merge-tree + server settings for comparison
SELECT * FROM system.merge_tree_settings INTO OUTFILE 'merge_tree_settings_before.csv' FORMAT CSV;
SELECT * FROM system.settings INTO OUTFILE 'settings_before.csv' FORMAT CSV;

-- Any stuck mutations (wait or cancel before upgrading a replica)?
SELECT database, table, command, parts_to_do, is_done
FROM system.mutations WHERE is_done = 0 ORDER BY create_time DESC;

-- Long-running merges?
SELECT database, table, round(progress * 100, 2) AS pct, elapsed
FROM system.merges ORDER BY elapsed DESC;

-- Replication health: no read-only replicas, drains should be small
SELECT database, table, replica_name, is_leader, is_readonly, future_parts, queue_size
FROM system.replicas WHERE is_readonly = 1 OR queue_size > 10;

What lights up at each version

After the upgrade

Open /overview — if it shows data, the connection and grants are intact. Re-check grants if you upgraded users; ClickHouse sometimes changes system-table visibility across majors:

SELECT count() FROM system.query_log LIMIT 1;
SELECT count() FROM system.processes LIMIT 1;
SELECT count() FROM system.replicas LIMIT 1;

Then roll forward one replica at a time, confirming each rejoins replication (is_readonly = 0, queue_size draining) before touching the next.

How chmonitor surfaces this

The AI agent can compare the system tables available now against what the dashboard expects and flag optional tables still missing. The Health page rolls cluster status into one grid so you see regressions immediately after cutover.