Integrate a ClickHouse instance
This topic describes how to integrate a ClickHouse cluster with Cloud Monitor 2.0. The integration component is a ClickHouse adapter based on aio-exporter. It collects metrics by querying system tables such as system.metrics, system.asynchronous_metrics, system.events, and system.parts through an HTTP interface. This process covers monitoring scenarios such as queries, connections, memory, MergeTree, replication, and ZooKeeper. The component supports two deployment environments: Container Service for Kubernetes (ACK) clusters and Elastic Compute Service (ECS) instances in a VPC. After the integration is complete, ClickHouse instance entities and a built-in dashboard are automatically generated.
Requirements
Before you start the integration, make sure that the target instance meets the following requirements. Otherwise, no data may be collected or some metrics may be missing.
|
Condition |
Requirement |
|
Version |
Supports ClickHouse versions that provide an HTTP interface. The default port is 8123. |
|
Deployment type |
Self-hosted ClickHouse. You can also connect to a managed instance if the account and network requirements are met. When you connect, select the corresponding cloud provider or deployment source. |
|
Monitoring account |
A dedicated read-only account is recommended. The account must have read permissions for |
|
Connection method |
Data is collected through the HTTP interface. The default port is 8123. |
|
Network connectivity |
For a CS environment, the target ClickHouse instance must be accessible from the selected ACK cluster network. For an ECS (VPC) environment, the vSwitch CIDR block of the managed agent must be able to access the target ECS instance. |
Prerequisites
-
Managed Service for Prometheus is activated.
-
For CS environments: The target ACK cluster is connected to Cloud Monitor 2.0 and is running. The target ClickHouse service is accessible from the cluster network.
-
For ECS (VPC) environments: The target ECS instance that hosts ClickHouse is accessible from the vSwitch CIDR block of the managed agent.
Billing
-
Billing is based solely on the volume of metric data generated in Billing overview.
Integration methods
Step 1: Prepare a monitoring account (if needed)
If access authentication is enabled for ClickHouse, create a monitoring account with read permissions for the system database. You can skip this step if authentication is not enabled. In the form, keep the username as default and leave the password empty.
Use a dedicated read-only account instead of a superuser. The monitoring account must have read permissions for at least the following:
-
system.metrics -
system.asynchronous_metrics -
system.events -
system.parts
Step 2: Select an integration environment
This plugin supports two integration environments: CS and ECS (VPC). These environments work differently. Select the environment based on where your ClickHouse service is deployed:
CS
-
Installs an exporter on a specified ACK cluster and uses the existing data collector in the cluster to collect metrics.
-
The monitored object is the ACK cluster.
-
Network requirements: The target ClickHouse service must be accessible from the cluster network, such as a service within the cluster or a private IP address in a VPC that the cluster can access.
ECS (VPC)
-
You select the ECS instance where the target ClickHouse service is deployed. The system then deploys a fully managed data collector based on the VPC information of that ECS instance.
-
No processes are installed on the ECS instance.
-
The monitored object is the ECS instance.
-
Network requirements: You must configure security group rules and ACLs to allow the vSwitch CIDR block of the managed agent to access the target ECS instance.
|
Environment |
Exporter deployment location |
Installs a process on the application server? |
Monitored object |
Network requirements |
|
CS |
Specified ACK cluster |
No. The exporter is deployed within the cluster and does not run on the host of the business pod. |
ACK cluster |
ClickHouse is accessible from the cluster network. |
|
ECS (VPC) |
Fully managed data collector deployed by the system based on the VPC. |
No. No processes are installed on the ECS instance. |
ECS instance |
The vSwitch CIDR block of the managed agent can access the target ECS instance. |
Step 3: Configure the integration
-
Log on to the Cloud Monitor console. Select the target workspace. In the navigation pane on the left, click Integration Center, and then click ClickHouse.
-
Select an integration environment (CS or ECS (VPC)) and select a Monitored Object from the drop-down list.
-
Configure the integration and click OK.
Configuration item
Required
Description
ClickHouse service endpoint
Yes
For a CS environment, enter the in-cluster endpoint. For an ECS (VPC) environment, enter the private or public endpoint (HTTP interface).
ClickHouse service port
Yes
Default: 8123 (HTTP).
Cloud vendor / Deployment source
No
This value is written to the
providerlabel of the metric and used for entity discovery. For a self-managed deployment, select 'Self-managed' (self-hosted/clickhouse).ClickHouse username
No
Default:
default. The account must have read permissions for the `system` database.ClickHouse password
No
Can be left empty if access authentication is not enabled.
Metric collection interval (seconds)
Yes
Default: 15. Value range: 1–60.
Custom tags
No
Extra labels to be added to metrics.
Use public image repository
No
Image repository access does not use the VPC Network by default. Enable this option if you are unable to access the internal repository.
-
After the integration is successful, you can view the integrated entities and their observable data in Entity Explorer.
Data usage
Entities
After integration, Cloud Monitor periodically discovers ClickHouse instances from the labels of metrics such as clickhouse_up and generates middleware entities:
|
Dimension |
Description |
|
Domain |
middleware |
|
Entity type |
middleware.clickhouse |
|
Entity filter condition |
|
|
Observed object (attached entity) |
CS environment: |
Entity fields are derived from collected labels and are not related to the number of installations:
|
Field |
Description |
|
instance_id |
Instance identity. This field is obtained from the |
|
provider |
Deployment source, such as |
|
port |
HTTP port. |
|
region_id |
Region. |
|
env_type |
Deployment environment type (CS or ECS). |
|
cluster_id |
Cluster identity. |
You can search for instances by these fields in the Entity Explorer or Middleware Insight applications.
Built-in dashboards
|
Dashboard name |
Access point |
Description |
|
ClickHouse Overview (Instance Overview) |
The Instance Overview tab on the entity details page. |
A UModel dashboard. Variables are automatically bound based on the instance context. |
|
ClickHouse Overview |
Grafana dashboard list. |
A Grafana dashboard. Available in both Chinese and English. |
Core metrics
The following is a complete list of metrics for the middleware.metric.clickhouse entity dataset. These metrics are available for direct use in entity details, dashboards, and alerts:
|
Metric name |
Type |
Unit |
Display name |
Description |
|
clickhouse_up |
gauge |
- |
ClickHouse Liveness |
Indicates whether the last data collection from ClickHouse was successful (whether the instance is reachable). A value of 1 indicates that the instance is live. A value of 0 indicates that the instance is unavailable. |
|
clickhouse_query_rate |
counter |
queries/second |
Query Rate |
The query execution rate, in queries per second (QPS). |
|
clickhouse_select_query_rate |
counter |
queries/second |
SELECT Query Rate |
The rate of SELECT queries, in QPS. |
|
clickhouse_insert_query_rate |
counter |
queries/second |
INSERT Query Rate |
The rate of INSERT queries, in QPS. |
|
clickhouse_active_queries |
gauge |
- |
Active Queries |
The number of queries that are currently running. |
|
clickhouse_failed_query_rate |
counter |
queries/second |
Failed Query Rate |
The rate of failed queries, in QPS. |
|
clickhouse_inserted_rows_rate |
counter |
rows/second |
Inserted Row Rate |
The number of rows inserted per second. |
|
clickhouse_inserted_bytes_rate |
counter |
Byte |
Byte write rate |
The number of bytes inserted per second. |
|
clickhouse_merge |
gauge |
- |
Running Merges |
The number of background merges that are in progress. |
|
clickhouse_part_mutation |
gauge |
- |
Partition Mutations |
The number of mutations (ALTER DELETE/UPDATE) that are in progress. |
|
clickhouse_parts_active |
gauge |
- |
Active Partition Count |
The number of active data parts in MergeTree tables. |
|
clickhouse_max_part_count_for_partition |
gauge |
- |
Maximum number of partitions |
The maximum number of active data parts in a single partition. A high value indicates a risk of a "too many parts" error. |
|
clickhouse_tcp_connection |
gauge |
- |
TCP Connections |
The current number of TCP connections. |
|
clickhouse_http_connection |
gauge |
- |
HTTP Connections |
The current number of HTTP connections. |
|
clickhouse_memory_tracking |
gauge |
bytes |
Memory Usage |
The total amount of memory (in bytes) tracked or allocated by the server-side. |
|
clickhouse_network_receive_bytes |
counter |
Byte |
Inbound Network Traffic |
The number of bytes received per second over the network. |
|
clickhouse_network_send_bytes |
counter |
Byte |
Outbound Network Traffic |
The number of bytes sent per second over the network. |
|
clickhouse_readonly_replica |
gauge |
- |
Read-only Replicas |
The number of replica tables that are currently in read-only mode. |
|
clickhouse_replicas_max_absolute_delay |
gauge |
seconds |
Max Replica Delay |
The maximum replication delay (in seconds) among all replica tables. |
|
clickhouse_replicated_fetch |
gauge |
- |
Replicated Fetches |
The number of background replica part fetches that are in progress. |
|
clickhouse_replicated_send |
gauge |
- |
Replicated Sends |
The number of background replica part sends that are in progress. |
|
clickhouse_replicated_checks |
gauge |
- |
Number of consistency checks for replicas |
The number of replica consistency checks that are currently running. |
|
clickhouse_zoo_keeper_session |
gauge |
- |
ZooKeeper Sessions |
The number of sessions established with ZooKeeper. |
|
clickhouse_zoo_keeper_watch |
gauge |
- |
ZooKeeper Watches |
The number of watches set on ZooKeeper. |
|
clickhouse_delayed_inserts |
gauge |
- |
Delayed Inserts |
The number of INSERT operations that are delayed due to rate limiting caused by too many active parts. |
|
clickhouse_distributed_files_to_insert |
gauge |
- |
Files to Insert for Distributed Tables |
The number of files pending to be sent for distributed tables. |
|
clickhouse_file_open_rate |
counter |
operations/second |
File Open Rate |
The number of file open operations per second. |
|
clickhouse_background_common_pool_task |
gauge |
- |
Background Common Pool Tasks |
The number of active tasks in the background common thread pool. |
|
clickhouse_background_schedule_pool_task |
gauge |
- |
Background Schedule Pool Tasks |
The number of active tasks in the background scheduling thread pool. |
|
clickhouse_kafka_consumers_in_use |
gauge |
- |
In-use Kafka Consumers |
The number of Kafka consumers that are currently in use. |
|
clickhouse_table_parts_bytes |
gauge |
bytes |
Table Part Size |
The total size (in bytes) of active parts, aggregated by database and table. |
|
clickhouse_table_parts_count |
gauge |
- |
Table Part Count |
The total number of active parts, aggregated by database and table. |
|
clickhouse_table_parts_rows |
gauge |
- |
Table Part Rows |
The total number of rows in active parts, aggregated by database and table. |
In addition to the aggregated metrics in the preceding MetricSet, all raw metrics collected by the exporter (with the clickhouse_* prefix) are written to Prometheus storage. These metrics can be queried directly using Prometheus Query Language (PromQL).
Example queries
# Liveness
clickhouse_up
# Query rate
rate(clickhouse_query[5m])
# Failed query rate
rate(clickhouse_failed_query[5m])
# Memory usage
clickhouse_memory_tracking
Alert templates
This integration component does not have built-in alert rules. You can configure alerts based on the preceding metrics in the Alert Center. For example, you can set an alert for scenarios where the clickhouse_up liveness metric is not equal to 1, or when the number of connections or the message accumulation exceeds a threshold.
Storage policies
After you integrate ClickHouse, Cloud Monitor creates a corresponding storage instance to store observable data.
|
Data type |
Default storage location |
Notes |
|
Metrics |
Prometheus instance: RegionShare:{{workspaceName}}:{{regionId}} |
Associated dataset: |
Manage or remove the integration
To modify or cancel the integration, go to the Integration Management page of Integration Center, find the corresponding integration policy, and then click Edit or Delete. When you delete the integration policy, the Exporter and the collection configuration are removed together. Historical metrics that have already been written are retained based on the lifecycle policy of the storage.