Skip to main content
The operator exposes Prometheus-compatible metrics and Kubernetes health probes so that you can observe its reconciliation activity, detect stalled controllers, and alert on failures. This guide covers what the operator exposes, how to scrape it, and which queries are useful day to day.
This guide is about the operator process itself (the controller manager). For ClickHouse server metrics (queries, parts, replication lag), use the Prometheus endpoint in ClickHouse to scrape it separately.

Endpoints

The operator process exposes two HTTP endpoints inside the manager pod: The metrics endpoint is off by default when running the operator binary directly (--metrics-bind-address=0). The Helm chart turns it on with metrics.enable: true and metrics.port: 8080. The health probe endpoint is always on; the deployment template wires /healthz and /readyz to the pod’s liveness and readiness probes on port 8081.

Operator binary flags

The relevant manager flags (defined in cmd/main.go):
The 8443 (HTTPS) / 8080 (HTTP) convention in the flag’s help text is only a hint. The Helm chart serves HTTPS on 8080 because it sets both metrics.port: 8080 and metrics.secure: true. There is no port-based mode detection — --metrics-secure is what selects HTTPS or HTTP.

Enable metrics via Helm

The chart already creates a Service for the metrics port and, optionally, a ServiceMonitor for prometheus-operator. The metrics endpoint itself is on by default (metrics.enable: true, port 8080, served over HTTPS via metrics.secure: true). The only setting you typically need to flip is prometheus.enable to have the chart create a ServiceMonitor for you:
If you do not use cert-manager, additionally set certManager.enable: false and the ServiceMonitor will scrape with insecureSkipVerify: true, relying on bearer-token authentication only. The full set of metrics-related defaults is:
Apply:
After install the chart creates:
  • Service/<resource-prefix>-metrics-service — exposes port 8080 (HTTPS when metrics.secure: true).
  • ServiceMonitor/<resource-prefix>-controller-manager-metrics-monitor — when prometheus.enable: true.
  • ClusterRole/<resource-prefix>-metrics-reader — non-resource URL /metrics with get verb.

Securing the metrics endpoint

When metrics.secure: true the metrics server enforces TLS and Kubernetes authentication/authorization on every scrape. Scrapers must:
  1. Present a valid Kubernetes bearer token.
  2. Belong to a ServiceAccount bound to a ClusterRole granting get on the non-resource URL /metrics.
The chart ships such a ClusterRole:
Bind it to the ServiceAccount used by your scraper (typically Prometheus):
If you see 401 Unauthorized or 403 Forbidden from the metrics endpoint, the scraper is using HTTPS but is missing/unauthorized for a Kubernetes bearer token, or its ServiceAccount lacks the binding above. Disabling security by setting metrics.secure: false is not recommended in shared clusters because anyone with network reachability to the pod could scrape the endpoint.

ServiceMonitor reference

The chart renders a ServiceMonitor of this shape when prometheus.enable: true:
If your Prometheus instance does not run cert-manager, set tlsConfig.insecureSkipVerify: true and rely on bearer-token authentication only — the chart already does this when certManager.enable: false.

Standalone Prometheus example

If you do not use kube-prometheus-stack, the repository ships a self-contained example at examples/prometheus_secure_metrics_scraper.yaml. It creates a ServiceAccount, the necessary RBAC, and a Prometheus CR that selects the operator’s ServiceMonitor.

Health probe endpoints

Both endpoints are registered with the same trivial ping check (healthz.Ping from sigs.k8s.io/controller-runtime). A failing probe therefore means “the manager process is not serving HTTP on :8081” — not “controllers are unhealthy”. To detect controller-level problems, use the reconciliation metrics instead. Both endpoints are served on port 8081 by default. They are wired to the deployment as:
A repeatedly failing probe usually means the probe server itself never came up — for example, the manager exited early during startup. Check the manager logs for unable to start manager, RBAC failures, or cache did not sync errors.

Metrics catalog

The operator does not register custom Prometheus collectors. Everything below is exposed by the underlying controller-runtime and client-go libraries. The most useful series, grouped by purpose:

Reconciliation activity

The controller label is derived by controller-runtime from the resource type registered with For(...). With the current code in internal/controller/clickhouse and internal/controller/keeper this resolves to clickhousecluster and keepercluster respectively. If you have customized the operator, verify with a one-time scrape of /metrics.

Work queue

The name and controller labels carry the same value (the controller name).

API server traffic

Leader election

The Helm chart enables --leader-elect by default, so this metric is present in standard Helm installs. When running the binary directly without the flag, the metric is absent.

Runtime

Standard Go process and runtime collectors — go_goroutines, go_memstats_*, process_cpu_seconds_total, process_resident_memory_bytes, etc.

Useful PromQL queries

Health overview

Backlog detection

Throttling and API pressure

Leader status (HA deployment)

Suggested alerts

Starting point for a PrometheusRule (tune thresholds for your environment):
The last rule is only meaningful when leader election is enabled.

Verifying the setup

A quick end-to-end check, assuming the chart was installed in clickhouse-operator-system:
If the scrape returns metrics in the Prometheus exposition format, the endpoint and RBAC are correctly wired.
Last modified on June 29, 2026