Prerequisites
- A running ClickHouse Private deployment
- Helm available on your workstation
kubectlaccess to the target cluster- The kube-prometheus-stack Helm chart and its container images available in your private registry (see Airgap image preparation below)
Steps
1. Install kube-prometheus-stack
Add the Prometheus community Helm repository to your local Helm client and pull the chart:Note: The kube-prometheus-stack bundles Prometheus, Alertmanager, Grafana, and the Prometheus Operator. Consult the chart documentation for the full list of images that must be mirrored to your private registry.
2. Enable PodMonitors in the ClickHouse Operator
The ClickHouse operator Helm chart includes PodMonitor definitions for ClickHouse Server and Keeper. Enable them in your operator Helm values:
Use the plain port for non-TLS deployments (
scrape.clickhouseServer, scrape.clickhouseKeeper) and the secure port for TLS deployments (scrape.clickhouseServerSecure, scrape.clickhouseKeeperSecure). See Expose Metrics over HTTPS for the full configuration.
Both PodMonitors carry the label release: kube-prometheus-stack, which matches the default podMonitorSelector of a kube-prometheus-stack Prometheus instance.
Note: If your Prometheus instance uses a different release name, update the PodMonitor label selector accordingly by overriding the operator chart templates or configuring prometheus.prometheusSpec.podMonitorSelector in the kube-prometheus-stack values.
3. Verify Prometheus Targets
After deploying, confirm that Prometheus discovers and scrapes the ClickHouse targets:http://localhost:9090/targets in a browser. Look for target groups named podMonitor/clickhouse-operator-system/clickhouse-server-metrics and podMonitor/clickhouse-operator-system/clickhouse-keeper-metrics. All targets should show a State of UP.
Run a test query to confirm metrics are flowing:
Note: Thejoblabel in Prometheus includes the namespace prefix:clickhouse-operator-system/clickhouse-server-metricsandclickhouse-operator-system/clickhouse-keeper-metrics. Use these full values in PromQL queries and Grafana dashboard filters.
4. Import the ClickHouse Grafana Mixin Dashboards
The ClickHouse Grafana mixin provides prebuilt dashboards for ClickHouse server and keeper metrics. In an airgapped environment, import the dashboard JSON files manually.Download dashboards
Download the mixin dashboard JSON files from the Grafana integration page or export them from an existing Grafana instance.Import via Grafana UI
- Open Grafana (bundled with kube-prometheus-stack):
- Log in at
http://localhost:3000(default credentials:admin/prom-operator). - Navigate to Dashboards > Import.
- Upload each dashboard JSON file or paste its contents.
- Select your Prometheus data source when prompted.
Import via ConfigMap
To manage dashboards as code, create a ConfigMap in the monitoring namespace with the Grafana sidecar label:grafana_dashboard: "1" label and loads the dashboards.
5. Configure Alert Rules (Optional)
Import the recommended ClickHouse alert rules into Prometheus by creating aPrometheusRule resource. See Configure alerting and Metrics and alerts reference for the full set of alert definitions.
Example:
Expose Metrics over HTTPS (Optional)
By default, Server and Keeper expose metrics on port8001 over plain HTTP. Both can be configured to serve metrics exclusively over HTTPS on port 8004 (prom-secure). When TLS is required, the plain port 8001 binding is removed.
Certificate Requirements
- A TLS certificate secret named
ch-<cluster-name>-cert-secretin the cluster namespace, containing keystls.key,tls.crt, andchaincert.pem
For details on certificate generation, SAN requirements, and secret key names see Configure Cert Manager for ClickHouse Certificates or Generate FIPS-Compliant Certificates for ClickHouse.
Expose Server Metrics over HTTPS
The Server pod exposesprom-secure (8004) only when server.openSSL.required=true is set in the cluster Helm values. This also disables all plain-text ports (8001, 8123, 9000), leaving only TLS listeners.
Enable
Upgrade the cluster Helm release with TLS required:Update the PodMonitor
Enable the secure scrape endpoint in the operator Helm values. DisableclickhouseServer (8001) and enable clickhouseServerSecure (8004) instead:
Expose Keeper Metrics over HTTPS
To expose Keeper metrics over HTTPS, Keeper must run in server-embedded mode. In this mode Keeper runs as a thread inside aclickhouse-server process and gains access to the TLS-capable HTTP handler stack, including prom-secure on port 8004.
For a full explanation of server-embedded mode, image registry requirements, and what running Keeper this way implies for your deployment, see Keeper-in-Server Mode.
Enable
Upgrade the cluster Helm release to switch Keeper to theclickhouse-server image and enable server-embedded mode:
Note: Add --set-json='keeper.featureFlags.disableNonSecureKeeperInServerPorts=true' if you want to disable all non-TLS Keeper ports.
Update the PodMonitor
Once Keeper pods are running in server-embedded mode with TLS, enable the secure scrape endpoint in the operator Helm values.clickhouse-keeper-metrics PodMonitor to scrape prom-secure (8004) over HTTPS using the provided certificate.
Enable the Custom Metrics Handler (Optional)
ClickHouse Server exposes additionalClickHouse_CustomMetric_* metrics including lost part counts, replica read-only duration, data corruption errors, async insert memory, and more. These are derived from SQL queries against system tables and are not available on the standard Prometheus endpoint. The endpoint requires authentication.
Add an HTTP handler rule to the cluster Helm values.
:
ClickHouse_CustomMetric_LostPartCount, replica read-only duration, and memory usage.
Apply via helm upgrade:
scheme: http and targetPort: 8123 for non-TLS, or scheme: https and targetPort: 8443 for TLS:
Prepare Images for Airgap
The kube-prometheus-stack requires the following container images. Mirror them to your private registry before installation:
Note: Exact image tags depend on the kube-prometheus-stack chart version you are deploying. Run helm template on the pulled chart to extract the exact image references for your version.