Skip to main content

Expose ClickHouse server metrics

If you’re using ClickHouse Cloud, you can expose metrics to Prometheus using the Prometheus Integration.
Configure a dedicated port when a Prometheus server needs to scrape ClickHouse’s own metrics:
Section <prometheus.handlers> can be used to make more extended handlers on the same port. This section is similar to <http_handlers> but works for prometheus protocols:
Settings: Check the endpoint:

Prometheus HTTP API and PromQL

ClickHouse implements the Prometheus HTTP API over a TimeSeries table. One handler serves remote write, remote read, instant PromQL queries, and range PromQL queries.

Prerequisites

Enable the allow_experimental_time_series_table setting for the user that creates and accesses the table:
Create a database and a TimeSeries table:
For HTTP API requests, enable allow_experimental_time_series_table in the profile of the API user.

Configure the Prometheus API

Configure one prefix-routed handler on the main ClickHouse HTTP port:
<defaults/> preserves the built-in handlers for endpoints such as /ping and for SQL requests. The prefix above exposes these endpoints through one handler: The example omits database and table from the handler. Each request must provide the table query parameter. It can also provide database, use a qualified table name such as prometheus.metrics, or omit the database to use default. This allows one handler to serve multiple TimeSeries tables. To use one fixed table for every request, configure it in the handler:
A table configured in the handler cannot be overridden by request parameters. Routing and handler settings:

Ingest metrics with remote write

ClickHouse supports the Prometheus remote-write protocol. Configure Prometheus to write to the handler:
Prometheus sends samples to the prometheus.metrics table.

Query with PromQL

Use the instant-query endpoint to evaluate a PromQL expression at one point in time:
Use the range-query endpoint to evaluate an expression over a time range:
See the supported PromQL features for the function and aggregation operator list used by the HTTP API, the promql dialect, and the table functions.

Grafana

Configure a Prometheus data source with the base URL ending before /api/v1:
Grafana appends /api/v1/query or /api/v1/query_range to this base URL and adds customQueryParameters to each request.
Only the query endpoints /api/v1/query and /api/v1/query_range are implemented. The metadata endpoints a Grafana Prometheus datasource uses for label browsing, template variables, and query-builder autocomplete (/api/v1/series, /api/v1/labels, /api/v1/label/<name>/values) are not implemented and return an error. Write PromQL expressions in code mode instead of the query builder.

SQL entry points

ClickHouse uses the same PromQL converter for the HTTP API, the promql dialect, and the prometheusQuery and prometheusQueryRange table functions. Run PromQL directly with clickhouse-client:
Use the table functions to embed PromQL in a SQL query:

Read metrics with remote read

ClickHouse supports the Prometheus remote-read protocol at /prometheus/api/v1/read. Configure a Prometheus server to read from the same TimeSeries table:
Last modified on August 17, 2026