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:
sudo vi /etc/clickhouse-server/config.xml
Search for prometheus inside the file. You will typically find a commented block like this:
<!--
<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</prometheus>
-->
Remove the comment tags <!-- --> so it becomes:
<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</prometheus>
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
sudo systemctl restart clickhouse-server
Step 5: Verify Prometheus Endpoint
curl http://<clickhouse-host>:9363/metrics

You should see metrics output in Prometheus format.
Update prometheus.yml:
Step 7: Reload Prometheus
sudo systemctl reload prometheus
Step 8: Validate in Prometheus UI
- Open:
http://<prometheus-host>:9090 - Check Targets
- Ensure status is UP