ClickHouse Configuration
ClickHouse serves as the primary analytics database for storing profiling data and metrics. It provides high-performance columnar storage optimized for analytical queries.
Configuration Modes​
- Use Existing
- Create Mode
Connect to existing ClickHouse​
This mode connects to your existing ClickHouse cluster, including ClickHouse Cloud, on-premises clusters, and single-node instances.
Supported ClickHouse Deployments
- ClickHouse Cloud: Managed ClickHouse service with automatic scaling and management
- ClickHouse Clusters: Multi-node distributed setups with shards and replicas
- Single-node ClickHouse: Standalone ClickHouse server installations
Database Setup Options​
You have two options for setting up the required databases:
- Manual Setup: Create databases and users manually using SQL commands.
- Automatic Setup: Enable
autoCreateDBsto let zymtrace create databases during migration
Option 1: Manual Database Setup​
When connecting to an existing ClickHouse cluster, we strongly recommend that you create a dedicated user, assign appropriate permissions, and create a new database for zymtrace.
If you're using a distributed ClickHouse cluster with multiple shards/replicas, you have two options:
- Use the
{cluster}macro (recommended): A common convention where{cluster}is configured as a macro that resolves to your cluster name - Find the actual cluster name: Query your ClickHouse installation to get the specific cluster name
-- Check if the {cluster} macro is available
SELECT * FROM system.macros;
-- Find available clusters in your ClickHouse installation
SELECT cluster FROM system.clusters;
SQL Commands for Database Setup​
Choose the appropriate commands based on your ClickHouse deployment.
This script will drop the zymtrace_profiling database if it exists. Run it only if this is your first time setting up zymtrace with ClickHouse, or if you intentionally want to reset the database, knowing that this will permanently delete any existing data.
- ClickHouse Cloud / Single Node
- ClickHouse Cluster
ClickHouse Cloud and Single Node​
For single-node ClickHouse installations or ClickHouse Cloud:
-- Clean slate: remove any existing profiling database
DROP DATABASE IF EXISTS zymtrace_profiling SYNC;
DROP DATABASE IF EXISTS zymtrace_metrics SYNC;
CREATE DATABASE zymtrace_profiling;
CREATE DATABASE zymtrace_metrics;
CREATE USER IF NOT EXISTS zymtrace_user
IDENTIFIED WITH sha256_password BY 'YOUR NEW PASSWORD HERE';
GRANT
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_profiling.* TO zymtrace_user;
GRANT
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_metrics.* TO zymtrace_user;
Note that SYSTEM SYNC REPLICA is only strictly required when running in ClickHouse Cloud and
optional when using a self-hosted single node instance.
Distributed ClickHouse Cluster Setup​
For ClickHouse clusters with multiple shards/replicas, you can use either the {cluster} macro or specify the actual cluster name:
Using the {cluster} macro (recommended)
-- Clean slate: remove any existing profiling database
DROP DATABASE IF EXISTS zymtrace_profiling ON CLUSTER '{cluster}' SYNC;
DROP DATABASE IF EXISTS zymtrace_metrics ON CLUSTER '{cluster}' SYNC;
CREATE DATABASE zymtrace_profiling ON CLUSTER '{cluster}';
CREATE DATABASE zymtrace_metrics ON CLUSTER '{cluster}';
CREATE USER IF NOT EXISTS zymtrace_user ON CLUSTER '{cluster}'
IDENTIFIED WITH sha256_password BY 'YOUR NEW PASSWORD HERE';
GRANT ON CLUSTER '{cluster}'
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_profiling.* TO zymtrace_user;
GRANT ON CLUSTER '{cluster}'
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_metrics.* TO zymtrace_user;
GRANT ON CLUSTER '{cluster}' REMOTE, CLUSTER ON *.* to zymtrace_user;
Alternative: Using the actual cluster name
Replace your_cluster_name with your actual cluster name from the system.clusters query above:
-- Clean slate: remove any existing profiling database
DROP DATABASE IF EXISTS zymtrace_profiling ON CLUSTER your_cluster_name SYNC;
DROP DATABASE IF EXISTS zymtrace_metrics ON CLUSTER your_cluster_name SYNC;
CREATE DATABASE zymtrace_profiling ON CLUSTER your_cluster_name;
CREATE DATABASE zymtrace_metrics ON CLUSTER your_cluster_name;
CREATE USER IF NOT EXISTS zymtrace_user ON CLUSTER your_cluster_name
IDENTIFIED WITH sha256_password BY 'YOUR NEW PASSWORD HERE';
GRANT ON CLUSTER your_cluster_name
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_profiling.* TO zymtrace_user;
GRANT ON CLUSTER your_cluster_name
SELECT,
INSERT,
UPDATE,
ALTER,
DELETE,
CREATE,
DROP,
SHOW,
OPTIMIZE,
TRUNCATE,
SYSTEM SYNC REPLICA
ON zymtrace_metrics.* TO zymtrace_user;
GRANT ON CLUSTER your_cluster_name REMOTE, CLUSTER ON *.* to zymtrace_user;
{cluster}macro: A common naming convention where{cluster}is configured as a macro that resolves to your cluster name. This approach works across different cluster configurations without hardcoding names.- Actual cluster name: Replace
your_cluster_namewith the actual cluster name from yoursystem.clustersquery. Common examples includeproduction_cluster,default_cluster, orch_cluster.
Make sure to replace YOUR NEW PASSWORD HERE with a secure password.
Reference - https://clickhouse.com/docs/sql-reference/statements/grant
Option 2: Automatic Database Setup​
Alternatively, you can enable autoCreateDBs: true in your configuration to let zymtrace automatically create the required databases during migration. This option requires that your ClickHouse user has CREATE permissions on the server.
When to use automatic setup:
- Development environments where quick setup is preferred
- When you have administrative access to grant broad CREATE permissions
- Testing scenarios where database recreation is acceptable
When to use manual setup:
- Production environments requiring strict permission control
- When following security best practices with minimal required permissions
- Enterprise environments with database administration policies
When using ClickHouse Cloud, ensure you use port 8443 and enable secure connection. For ClickHouse clusters, specify the cluster name to enable distributed queries.