Enable Bundled Prometheus Exporter for ClickHouse DB

Enable Bundled Prometheus Exporter for ClickHouse DB

Overview

      ClickHouse provides a built-in Prometheus exporter that allows monitoring tools like Prometheus to scrape internal metrics directly from the database. This eliminates the need for any external exporter in modern setups. In the default ClickHouse configuration, the Prometheus exporter settings are already available but kept commented out. Enabling the exporter requires uncommenting and activating this configuration.

Supported Versions

      The bundled Prometheus exporter is available starting from ClickHouse 19.x and above. For older versions, an external exporter such as clickhouse_exporter must be used.

Step 1: Open ClickHouse Configuration

Go to the main config file:

Quotesudo vi /etc/clickhouse-server/config.xml

Step 2: Locate Commented Prometheus Section

Search for prometheus inside the file. You will typically find a commented block like this:

Quote<!--
<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</prometheus>
-->

Step 3: Uncomment the Prometheus Block

Remove the comment tags <!-- --> so it becomes:

Quote<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</prometheus>

Notes
Note: f the port number or endpoint needs to be modified, update the configuration as required. The default values are suitable for most setups.

Step 4: Restart ClickHouse Service

Quotesudo systemctl restart clickhouse-server

Step 5: Verify Prometheus Endpoint

Quotecurl http://<clickhouse-host>:9363/metrics

Info
You should see metrics output in Prometheus format.

Step 6: Configure Prometheus Scrape Job

Update prometheus.yml:

Quote
scrape_configs:
- job_name: 'clickhouse'
static_configs:
- targets: ['<clickhouse-host>:9363']

Step 7: Reload Prometheus

Quotesudo systemctl reload prometheus

Step 8: Validate in Prometheus UI

  • Open: http://<prometheus-host>:9090
  • Check Targets
  • Ensure status is UP

                  New to ADSelfService Plus?