Prerequisites
- ClickHouse 21.x or later
- Network access from the OpenSRE environment to your ClickHouse instance
- A user with read access to system tables
Setup
Option 1: Interactive CLI
Option 2: Environment variables
Add to your.env:
| Variable | Default | Description |
|---|---|---|
CLICKHOUSE_HOST | — | Required. ClickHouse hostname or IP |
CLICKHOUSE_PORT | 8123 | HTTP(S) port (8123 for HTTP, 8443 for HTTPS) |
CLICKHOUSE_DATABASE | default | Default database |
CLICKHOUSE_USER | default | Username |
CLICKHOUSE_PASSWORD | — | Password |
CLICKHOUSE_SECURE | false | Use HTTPS (true/false) |
Option 3: Persistent store
Creating a read-only user
Investigation tools
When OpenSRE investigates a ClickHouse-related alert, three diagnostic tools are available:- Query activity — reads
system.query_logto surface recent slow and failed queries - System health — reads
system.metricsfor active connections, query count, replica status, and uptime - Table stats — reads
system.partsfor table-level row counts and storage sizes
Verify
Troubleshooting
| Symptom | Fix |
|---|---|
| Connection refused | Check host, port, and firewall. Use port 8443 with CLICKHOUSE_SECURE=true |
| Authentication failed | Verify username and password |
| SSL error | Set CLICKHOUSE_SECURE=true and use port 8443 |
| Access denied on system tables | Grant SELECT ON system.* to the OpenSRE user |
Security best practices
- Create a dedicated read-only user with access only to
system.*and the databases OpenSRE needs. - Use HTTPS (
CLICKHOUSE_SECURE=true) in production. - Store credentials in
.env, not in source code.