Skip to content

ClickHouse

The ClickHouse integration scrapes the server’s built-in Prometheus endpoint with the collector’s prometheus receiver and parses the ClickHouse server log. Connecting it adds the Clickhouse Overview dashboard. In the app the integration is called Clickhouse.

Use this page when you want to monitor a ClickHouse server or cluster of your own, such as the one behind an analytics product.

  • ClickHouse v23 or newer. Check with SELECT version();.

  • An otelcol-contrib collector, v0.88.0 or newer, where you can add config files and environment variables. See Integrations.

  • For metrics: ClickHouse exposes Prometheus metrics, and the collector can reach that port. Turn it on with the prometheus server setting, for example:

    /etc/clickhouse-server/config.d/prometheus.xml
    <clickhouse>
    <prometheus>
    <endpoint>/metrics</endpoint>
    <port>9363</port>
    <metrics>true</metrics>
    <events>true</events>
    <asynchronous_metrics>true</asynchronous_metrics>
    <errors>true</errors>
    </prometheus>
    </clickhouse>
  • For logs: the collector can read the server log file, usually /var/log/clickhouse-server/clickhouse-server.log. The logger setting shows where it is.

clickhouse-metrics.yaml
receivers:
prometheus/clickhouse:
config:
global:
scrape_interval: 60s
scrape_configs:
- job_name: clickhouse
static_configs:
- targets:
- ${env:CLICKHOUSE_PROM_METRICS_ENDPOINT}
metrics_path: ${env:CLICKHOUSE_PROM_METRICS_PATH}
processors:
# Adds host.name. Remove when the collector runs on another host.
resourcedetection/system:
detectors: ["system"]
system:
hostname_sources: ["os"]
exporters:
otlp/fusescope:
endpoint: ${env:OTLP_DESTINATION_ENDPOINT}
tls:
insecure: true
service:
pipelines:
metrics/clickhouse:
receivers: [prometheus/clickhouse]
processors: [resourcedetection/system]
exporters: [otlp/fusescope]
Variable Example Description
CLICKHOUSE_PROM_METRICS_ENDPOINT clickhouse:9363 Prometheus host:port on the ClickHouse server.
CLICKHOUSE_PROM_METRICS_PATH /metrics Prometheus path.
OTLP_DESTINATION_ENDPOINT fusescope-collector.example.com:4317 FuseScope collector, OTLP gRPC.

Run the collector with --config clickhouse-metrics.yaml --config clickhouse-logs.yaml, as shown in Run the collector. Set insecure: false in the exporter when the FuseScope endpoint uses TLS.

  1. Open Integrations › Clickhouse.
  2. Click Connect Clickhouse, then I have already configured.
  3. Click Test Connection. The badge reads This integration is working properly once logs with source = clickhouse or ClickHouse metrics arrive. Until then it reads Listening for data….

Clickhouse Overview dashboard, with a host.name variable:

  • Rate of Queries, Failed Queries, Total Query Time
  • Inserted Rows, Inserted Data, Rejected Writes
  • Background Merges Launched, Total Time spent for Background Merges
  • Memory Usage, CPU, Disk, Network Traffic

No log pipelines and no alert rules. Parsing happens in the collector config; see Log pipelines for more.

Field Path Type
Timestamp timestamp timestamp
Severity Text severity_text string
Severity Number severity_number number
Thread ID attributes.thread_id string
Query ID attributes.query_id string
Clickhouse Component attributes.clickhouse_component string
Source attributes.source (clickhouse) string

The Prometheus endpoint exposes more than 1,700 metrics in four families:

Prefix Count What it is
ClickHouseProfileEvents_ 525 Counters of events since start, from system.events.
ClickHouseMetrics_ 248 Current values, from system.metrics.
ClickHouseAsyncMetrics_ 362 Values computed in the background, from system.asynchronous_metrics.
ClickHouseErrorMetric_ 582 Errors by error code since the last restart, from system.errors.

The dashboard uses these. The Data Collected tab lists them all.

Metric Type Unit Description
ClickHouseProfileEvents_Query Counter Number Queries to be interpreted and potentially executed.
ClickHouseProfileEvents_SelectQuery Counter Number SELECT queries.
ClickHouseProfileEvents_InsertQuery Counter Number INSERT queries.
ClickHouseProfileEvents_FailedQuery Counter Number Failed queries.
ClickHouseProfileEvents_FailedSelectQuery Counter Number Failed SELECT queries.
ClickHouseProfileEvents_FailedInsertQuery Counter Number Failed INSERT queries.
ClickHouseProfileEvents_QueryTimeMicroseconds Counter Microseconds Total time of all queries.
ClickHouseProfileEvents_SelectQueryTimeMicroseconds Counter Microseconds Total time of SELECT queries.
ClickHouseProfileEvents_InsertQueryTimeMicroseconds Counter Microseconds Total time of INSERT queries.
ClickHouseProfileEvents_InsertedRows Counter Number Rows inserted into all tables.
ClickHouseProfileEvents_InsertedBytes Counter Number Uncompressed bytes inserted into all tables.
ClickHouseProfileEvents_AsyncInsertQuery Counter Number Asynchronous INSERT queries.
ClickHouseProfileEvents_RejectedInserts Counter Number Inserts rejected with “Too many parts”.
ClickHouseProfileEvents_RejectedMutations Counter Number Mutations rejected with “Too many mutations”.
ClickHouseProfileEvents_Merge Counter Number Background merges launched.
ClickHouseProfileEvents_MergesTimeMilliseconds Counter Milliseconds Time spent on background merges.
ClickHouseMetrics_MemoryTracking Gauge Bytes Memory allocated by the server.
ClickHouseMetrics_Query Gauge Number Queries running now.
ClickHouseProfileEvents_OSCPUVirtualTimeMicroseconds Counter Microseconds CPU time seen by the OS.
ClickHouseProfileEvents_OSCPUWaitMicroseconds Counter Microseconds Time waiting for CPU.
ClickHouseProfileEvents_OSReadBytes Counter Number Bytes read from disk, excluding page cache.
ClickHouseProfileEvents_OSWriteBytes Counter Number Bytes written to disk.
ClickHouseProfileEvents_NetworkReceiveBytes Counter Number Bytes received from the network.
ClickHouseProfileEvents_NetworkSendBytes Counter Number Bytes sent to the network.