Monitor and optimize your ClickHouse databases
DB24x7 provides comprehensive monitoring for ClickHouse databases, including query performance analysis, distributed table monitoring, replication tracking, merge operations, and cluster health insights.
Supported Versions
ClickHouse 20.3+, 21+, 22+, 23+
Real-time Monitoring
System table insights
Query Analysis
Query log and performance metrics
Cluster Support
Multi-node cluster monitoring
Configure ClickHouse to log queries for performance analysis and monitoring.
Edit config.xml or Add to config.d/
<!-- /etc/clickhouse-server/config.d/query_log.xml -->
<clickhouse>
<query_log>
<database>system</database>
<table>query_log</table>
<partition_by>toYYYYMM(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
<!-- Enable query thread log for detailed analysis -->
<query_thread_log>
<database>system</database>
<table>query_thread_log</table>
<partition_by>toYYYYMM(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_thread_log>
</clickhouse>Verify Query Logging is Active
-- Check if query_log table exists
SHOW TABLES FROM system LIKE 'query_log';
-- Verify recent queries are being logged
SELECT
count() as query_count,
max(event_time) as last_logged_query
FROM system.query_log
WHERE event_time > now() - INTERVAL 1 HOUR;Restart ClickHouse Server
sudo systemctl restart clickhouse-server
Create a dedicated ClickHouse user with read-only access for monitoring.
Create Read-Only User
-- Create monitoring user with password CREATE USER db24x7_monitor IDENTIFIED WITH sha256_password BY 'your_secure_password'; -- Grant SELECT privileges on system tables GRANT SELECT ON system.* TO db24x7_monitor; -- Grant SELECT on your databases (repeat for each database) GRANT SELECT ON your_database.* TO db24x7_monitor; -- Grant cluster access for distributed queries GRANT SHOW ON *.* TO db24x7_monitor;
Alternative: Using XML Configuration
<!-- /etc/clickhouse-server/users.d/db24x7_monitor.xml -->
<clickhouse>
<users>
<db24x7_monitor>
<password_sha256_hex>SHA256_HASH_HERE</password_sha256_hex>
<networks>
<ip>DB24X7_IP_ADDRESS/32</ip>
</networks>
<profile>readonly</profile>
<quota>default</quota>
<allow_databases>
<database>system</database>
<database>your_database</database>
</allow_databases>
</db24x7_monitor>
</users>
</clickhouse>Verify User Creation
-- List all users SELECT name FROM system.users; -- Check user grants SHOW GRANTS FOR db24x7_monitor;
Network Security
Restrict user access to specific IP addresses using the networks configuration for enhanced security.
Use the following connection string formats to connect DB24x7 to your ClickHouse database:
HTTP Interface (Recommended)
clickhouse://db24x7_monitor:your_secure_password@hostname:8123/default
HTTPS Interface
clickhouse://db24x7_monitor:password@hostname:8443/default?secure=true
Native Protocol
clickhouse://db24x7_monitor:password@hostname:9000/default?protocol=native
Cluster Connection
clickhouse://db24x7_monitor:password@hostname:8123/default?cluster=my_cluster
Connection Parameters
| hostname | ClickHouse server address |
| 8123 | Default HTTP interface port |
| 9000 | Default native protocol port |
| secure | Enable HTTPS/TLS (true/false) |
| cluster | Cluster name for distributed queries |
Common connection issues:
# Check if ClickHouse is running sudo systemctl status clickhouse-server # Test HTTP interface curl http://localhost:8123/ping
Verify user credentials and permissions:
-- Check if user exists SELECT name FROM system.users WHERE name = 'db24x7_monitor'; -- Verify user can query system tables SELECT count() FROM system.query_log LIMIT 1; -- Check network restrictions SELECT * FROM system.users WHERE name = 'db24x7_monitor' FORMAT Vertical;
Verify query logging configuration:
-- Check if query_log is enabled
SELECT
database,
table,
engine
FROM system.tables
WHERE database = 'system' AND table = 'query_log';
-- If empty, check server logs
sudo tail -f /var/log/clickhouse-server/clickhouse-server.logVerify cluster configuration:
-- List available clusters SELECT cluster FROM system.clusters; -- Check cluster nodes SELECT * FROM system.clusters WHERE cluster = 'my_cluster'; -- Verify inter-node connectivity SELECT * FROM system.replication_queue;
Once your ClickHouse database is connected, you can: