ClickHouse fails quietly. The server process is fine and answers Ok., but one replica lost its Keeper session an hour ago and went read-only, the insert pipeline has been erroring since midnight, and the dashboards still render because they are reading yesterday's data. Nothing is "down" in the sense a basic uptime check understands.

ClickHouse's HTTP interface is unusually good for external monitoring, because an HTTP monitor can run a real query with nothing but a URL and two headers. This guide covers a self-managed server or cluster: two built-in endpoints, a query check, a trick that turns any SQL condition into an HTTP status code, and heartbeats for the parts no outside request can see. It follows the same shape as our guides for Elasticsearch and OpenSearch and Postgres replication.

What ClickHouse exposes over HTTP

By default the server listens on port 8123 for HTTP; 8443 can be enabled for HTTPS. All paths below are on that interface.

RequestHealthy answerWhat it proves
GET /200, Ok. (the default of http_server_default_response)The HTTP server is listening
GET /ping200, Ok. and a line feed, alwaysThe same; this is the documented health check
GET /replicas_status200 when the replica is available and not delayed; 503 with information about the gap otherwiseReplication on this node is keeping up
GET /?query=SELECT%201200, 1; a failed query is 500 with the error textAuthentication and the query path work
GET /dashboardThe built-in metrics dashboard; needs a user and passwordFor humans, not for a monitor

Two rules from the documentation shape everything else. Requests made with GET are read-only, so a monitor that sends GET cannot modify data even with a careless query. And if no user is named, the request runs as default with an empty password, which on a hardened server means it is refused; query checks need credentials.

Step 1: liveness with /ping

Create an HTTP monitor for https://clickhouse.example.com:8443/ping with expected status 200. This works on CronAlert's Free plan at a 3-minute interval. It catches a dead process, a full disk that stopped the server from starting, a lapsed certificate (SSL expiry is checked on every HTTPS monitor), and a broken proxy in front of it.

It catches nothing else, by design: the handler always returns Ok.. Treat it as the check that tells you the box is on.

Step 2: replication with /replicas_status

On a replicated setup, add one monitor per replica for /replicas_status, expected status 200. ClickHouse answers 200 if the replica is available and not delayed behind the others and 503 with details of the gap if it is. The monitoring documentation pairs this endpoint with the max_replica_delay_for_distributed_queries setting, whose default is 300 seconds, so out of the box the monitor goes red when a replica is roughly five minutes behind.

Monitor each replica by its own hostname. A monitor aimed at a load balancer tells you about whichever node answered, and the lagging replica may be the one that did not. Whether the endpoint demands credentials depends on your access configuration, so confirm what your server returns before trusting a green check:

curl -i https://ch-replica-2.example.com:8443/replicas_status

Step 3: a monitoring user and a real query

Create a user that can do nothing but read what the checks need:

CREATE USER uptime IDENTIFIED BY 'a-long-random-password' SETTINGS readonly = 1;
GRANT SELECT ON system.replicas TO uptime;
GRANT SELECT ON analytics.events TO uptime;   -- only the tables your checks query

ClickHouse accepts credentials three ways: HTTP basic auth, user and password URL parameters, and the X-ClickHouse-User and X-ClickHouse-Key headers. The documentation recommends against the URL parameters because they end up in proxy logs, and a URL with embedded credentials is a poor thing to store anywhere. Use the headers. CronAlert sends custom headers on every plan:

{
  "X-ClickHouse-User": "uptime",
  "X-ClickHouse-Key": "a-long-random-password"
}

Then the monitor URL is https://clickhouse.example.com:8443/?query=SELECT%201 with expected status 200. A wrong password, a revoked user, a server that accepts connections but cannot execute, and a proxy that swallows the path all produce something other than 200. Test with curl -i first so you know the monitor is exercising the query path and is not reading a 200 from the proxy.

Step 4: turn a condition into a status code with throwIf

This is the part that makes ClickHouse pleasant to monitor. throwIf(condition, 'message') raises an exception when the condition is true, and an exception makes the HTTP interface return 500 with the message in the body. So any fact you can state in SQL becomes "200 or not 200", which is exactly what an HTTP monitor checks first, and it needs no keyword assertion.

A replica that went read-only or lost Keeper:

SELECT throwIf(count() > 0, 'replica read-only or Keeper session expired')
FROM system.replicas
WHERE is_readonly OR is_session_expired

Ingestion stopped: the newest row is older than it should be.

SELECT throwIf(max(event_time) < now() - INTERVAL 10 MINUTE, 'no events for 10 minutes')
FROM analytics.events
WHERE event_date >= today() - 1

URL-encode the query and add wait_end_of_query=1 (explained in the next section). curl will do the encoding for you and print the URL to paste into the monitor:

curl -sS -G -o /dev/null -w '%{http_code}  %{url_effective}\n' \
  -H 'X-ClickHouse-User: uptime' -H 'X-ClickHouse-Key: a-long-random-password' \
  --data-urlencode "query=SELECT throwIf(count() > 0, 'replica read-only') FROM system.replicas WHERE is_readonly OR is_session_expired" \
  --data-urlencode "wait_end_of_query=1" \
  https://clickhouse.example.com:8443/

Three cautions. The check runs every one to three minutes forever, so keep it cheap: bound the freshness query to the most recent partition, as the event_date filter does, so that it reads a few granules and not the table. Pick a freshness window wider than your quietest normal period, or the monitor will page you every night at 3 a.m. when traffic is thin. And write one monitor per condition; CronAlert alerts name the monitor, so "ClickHouse · events freshness" in the subject line is the diagnosis.

On Pro, a keyword assertion is an alternative for cases where you would prefer a readable body to an exception: have the query return if(count() = 0, 'replicas_ok', 'replicas_degraded') and assert that the body contains replicas_ok. Each monitor has one assertion, so it is one condition per monitor either way.

The 200 that is not a success

ClickHouse streams results. If a query fails after the server has begun sending the response, the 200 header has already gone out and the error text arrives in the body. The documentation is blunt about it: a 200 response code does not guarantee that a query was successful, and the only way to catch every error is to inspect the body.

For monitoring queries the exposure is small, because a single aggregated value is computed before anything is sent, but remove the doubt anyway. Add wait_end_of_query=1 to the URL; the response is buffered and the status code reflects the outcome. It is one of the cases in why a monitor says up while the service is down.

Step 5: ClickHouse Keeper

Replication, distributed DDL, and replicated inserts all depend on ClickHouse Keeper (or ZooKeeper). Keeper does not speak HTTP on its client port; it answers ZooKeeper-style four-letter commands, of which ruok replies imok and mntr prints metrics. An HTTP monitor cannot send those, so use a heartbeat (Pro): a cron entry on each Keeper node that pings only when the node says it is fine.

* * * * * [ "$(echo ruok | nc -w 2 localhost 9181)" = imok ] && curl -fsS -m 10 https://cronalert.com/api/heartbeat/YOUR_TOKEN > /dev/null

Use the port from your own keeper_server configuration: the documentation's settings table gives 2181 as the default tcp_port, while its command examples use 9181. Set the heartbeat's expected interval to 1 minute with a grace of a few minutes. Keeper also has an optional HTTP readiness endpoint, configured under http_control (the documented example uses port 9182 and /ready); if you enable it and can reach it, check its behaviour with curl -i and it becomes an ordinary HTTP monitor. Where the client port is reachable and you only want to know it accepts connections, a TCP port monitor (Pro) covers that, as it does for the native protocol port your applications use.

Note what the read-only query in step 4 already gives you: a replica that has lost Keeper reports is_session_expired or is_readonly, so that monitor fails from the outside when Keeper is unreachable from the server's point of view, which is the failure that matters.

Step 6: backups

ClickHouse has a native BACKUP statement that writes to a configured disk, to S3, or to Azure Blob Storage, and records progress in system.backups, where a failed run shows BACKUP_FAILED. Nothing tells you when the nightly job simply did not run. Ping a heartbeat only when the client exits successfully:

#!/bin/sh
set -e
clickhouse-client --query "BACKUP DATABASE analytics TO S3('https://s3.example.com/ch-backups/$(date +%F)/', '$KEY_ID', '$SECRET')"
curl -fsS -m 10 https://cronalert.com/api/heartbeat/YOUR_TOKEN > /dev/null

Set the heartbeat's interval to one day with a grace period that covers the longest normal backup. A second backup started while one is running fails with CONCURRENT_ACCESS_NOT_SUPPORTED, so a job that overruns into the next night's schedule shows up as a missed ping, which is what you want. Database backup monitoring goes further, including restore tests.

Private clusters, proxies, and bare IPs

  • Do not open 8123 to the internet for the sake of a monitor. If the cluster is private, run the same checks from inside as a script that pings a heartbeat, one per condition: clickhouse-client --query "SELECT throwIf(…)" && curl …. The client exits non-zero when the query throws.
  • Behind a reverse proxy, restrict what is reachable to the paths you monitor, terminate TLS there, and keep ClickHouse's own access control on. CronAlert checks run from Cloudflare's network and have no fixed IP list to allowlist; the credential headers are the access control. The reverse proxy guide has the pattern.
  • Use a hostname. An HTTP monitor cannot reach a bare IP address from Cloudflare's network. Give the server a DNS name, or use a TCP port monitor, which can.
  • Metrics are a different job. ClickHouse can expose a Prometheus endpoint (the documented example block uses port 9363 and /metrics), and system.metrics, system.events, and system.asynchronous_metrics hold the numbers behind it. Use those for trends and capacity; use the checks here for "is it broken right now". Uptime monitoring vs APM vs logging draws the line.
  • Managed services run Keeper and replication for you, so steps 2 and 5 do not apply; the query and freshness checks still do. If your service is set to pause when idle, remember that a query every minute counts as activity.

A reasonable set

MonitorTypePlanCatches
/ping per nodeHTTP, 200FreeServer down, certificate expiry, proxy failure
/replicas_status per replicaHTTP, 200FreeReplication lag
throwIf on system.replicasHTTP, 200, headersFreeRead-only replica, lost Keeper session, bad credentials
throwIf on newest rowHTTP, 200, headersFreeIngestion stopped
Keeper ruokHeartbeatProKeeper node unhealthy
Nightly BACKUPHeartbeatProBackup failed or never ran

Free checks run every 3 minutes; Pro ($5/month) runs them every minute and adds heartbeats, keyword assertions, and TCP port monitors.

Frequently asked questions

Is /ping enough?

No. It always returns Ok. while the process is up, whatever the state of replication, Keeper, or your data. Keep it as the liveness check and add at least one query check.

Will a monitoring query every minute hurt performance?

Not if it is written for the purpose: an aggregate over system.replicas or over the latest partition of one table is cheap. A max() over an unfiltered billion-row table is not. Check the query's cost once with EXPLAIN or the query log before leaving it on a schedule.

Can the monitor send the query in a POST body?

CronAlert's HTTP monitors do not send a request body, so the query goes in the URL of a GET. That suits monitoring: GET requests are read-only in ClickHouse.

What about the "200 but failed" problem with throwIf?

An exception raised while computing a single aggregate happens before any output is sent, so the status is 500. Adding wait_end_of_query=1 makes that a guarantee and costs nothing for a one-value result.

How do I monitor insert pipelines feeding ClickHouse?

The freshness check covers the outcome whatever the pipeline is. For the pipeline itself, see message queue monitoring and Airbyte and dbt.

Get started

Start with /ping and one throwIf freshness check; those two monitors separate "the server is on" from "the data is current", which is the distinction ClickHouse outages usually turn on. Create a free CronAlert account and add them in a few minutes. Related reading: Elasticsearch and OpenSearch cluster health, Postgres replication lag, building a database health endpoint, self-hosted Sentry and Plausible (both run on ClickHouse), and custom headers and expected status codes.