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.
Data Retention​
The Helm chart renders the clickhouse.retention value into a retention YAML file and mounts it into the database
migration job. The migration job applies the file after schema migrations on every install and upgrade, updating TTL
clauses and related MergeTree settings on existing profiling and metrics tables.
The default Helm configuration deletes profiling data, metrics, and settled recommendations after 720 hours (30 days):
clickhouse:
retention:
common:
delete: { after-hours: 720 }
recommendations:
delete: { after-hours: 720 }
Set delete: disabled to retain a section's data indefinitely. ClickHouse processes expired data asynchronously during
merges, so rows can remain visible after the configured time has elapsed.
Retention sections​
The configuration requires common and recommendations sections:
commonconfigures profiling and metrics tables.recommendationsconfigures recommendations tables.
The optional top-level apply key controls how the migration job runs retention ALTER statements. sync (the
default) waits for every replica and fails the migration once ClickHouse's distributed_ddl_task_timeout elapses
(180 seconds by default). async submits the statements without waiting. Use async when TTL changes on large
tables or clusters exceed the timeout.
The following example applies retention asynchronously, deletes common data after 7 days, moves it to the cold
volume after 1 day, and recompresses it with ZSTD level 7 after 3 days. Recommendations remain for 60 days.
clickhouse:
retention:
apply: async
common:
policy: tiered
delete: { after-hours: 168 }
tiers:
- move: { after-hours: 24, to: { volume: cold } }
- recompress: { after-hours: 72, codec: { zstd: 7 } }
settings:
merge-with-ttl-timeout-sec: 14400
ttl-only-drop-parts: true
recommendations:
delete: { after-hours: 1440 }
policy must name a ClickHouse storage policy available on every target server. Each move destination must be a disk
or volume defined by that policy.
ClickHouse Cloud does not support custom storage policies or TTL TO DISK/TO VOLUME moves, so the policy and
tiers[].move options only apply to self-hosted deployments. ClickHouse Cloud manages data tiering automatically;
see Implementing a hot/warm/cold architecture.
delete retention works on all deployments.
| Field | Values | Behavior |
|---|---|---|
apply (top-level) | sync (default) or async | sync waits for retention ALTERs on every replica; async submits them without waiting. |
policy | ClickHouse storage policy name | Sets the table's storage_policy. Required when tier rules move data outside the current policy. |
delete | disabled or { after-hours: HOURS } | Removes expired data or retains it indefinitely. HOURS must be a positive integer. |
tiers[].move | { after-hours: HOURS, to: { volume: NAME } } or { after-hours: HOURS, to: { disk: NAME } } | Moves data to a ClickHouse volume or disk. |
tiers[].recompress | { after-hours: HOURS, codec: CODEC } | Recompresses data with lz4, { lz4hc: LEVEL } (1–12), or { zstd: LEVEL } (1–22). |
settings.merge-with-ttl-timeout-sec | Non-negative integer | Sets the minimum delay between delete-TTL merges. ClickHouse defaults to 14400 seconds. |
settings.ttl-only-drop-parts | Boolean | Drops complete expired parts instead of deleting rows where supported. Defaults to true. |
Override retention settings​
Helm deep-merges clickhouse.retention with the chart defaults, so a values file only needs the fields it changes.
Overriding common keeps the default recommendations section, and vice versa. Individual fields can also be set on
the command line:
helm upgrade --install backend zymtrace/backend \
--namespace zymtrace \
--set clickhouse.retention.common.delete.after-hours=168
Misspelled section names and sections without a delete rule fail at template time; the migration job validates the
remaining fields before applying any changes.
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.
Helm Configuration​
- ClickHouse Cloud / Single Node
- ClickHouse Cluster
ClickHouse Cloud / Single Node​
This configuration applies to both ClickHouse Cloud and standalone single-node ClickHouse installations.
clickhouse:
mode: "use_existing"
use_existing:
host: "https://abc123def.us-east-1.aws.clickhouse.cloud:8443" # For ClickHouse Cloud,
# OR "http://clickhouse.internal.company.com:8123" # For single-node
user: "default" # For Cloud, or "zymtrace_user" for single-node
password: "your-cloud-password" # For Cloud, or "secure-password" for single-node
database: "zymtrace"
secure: true # For Cloud, or false/true for single-node depending on TLS
# clusterName not needed for Cloud or single-node
# autoCreateDBs: true # or create the DBs yourself using the SQL above
ClickHouse Cluster (On-premises)​
This configuration applies to distributed ClickHouse clusters with multiple nodes, shards, or replicas.
clickhouse:
mode: "use_existing"
use_existing:
host: "https://your-instance.region.provider.clickhouse.cloud:8443" # Complete URL with protocol and port
user: "default" # Your ClickHouse username
password: "your-password" # Your ClickHouse password
database: "zymtrace" # Database prefix - creates zymtrace_profiling and zymtrace_metrics
secure: true # Enable TLS/secure connection (required for ClickHouse Cloud)
clusterName: "" # Optional: ClickHouse cluster name for distributed setups (e.g., "production_cluster").
# Required when using ClickHouse clusters with multiple shards/replicas.
# You can use either the actual cluster name or "{cluster}" macro if configured.
# When enabled, we use the ON CLUSTER macro for distributed queries across cluster nodes.
# Leave empty for ClickHouse Cloud or single-node ClickHouse instances.
autoCreateDBs: false # When true, zymtrace migration will automatically create the required databases.
# NOTE: For autoCreateDBs to work, the database user must have CREATE DATABASE permission.
# Grant with: GRANT CREATE ON *.* TO your_user;
HTTP Interface Requirement​
Only the ClickHouse HTTP interface is supported due to limitations in the official ClickHouse Rust client. The native protocol port is not supported. Always use the HTTP interface port:
- HTTP: Port 8123 (typically for internal/dev environments)
- HTTPS: Port 8443 (recommended for production and ClickHouse Cloud)
URL Format Requirements​
The host field must include:
- Protocol:
http://orhttps:// - Hostname/IP: The ClickHouse server address
- Port: The HTTP interface port
Next Steps​
After configuring ClickHouse, proceed to configure the other storage components:
Deploy new ClickHouse instance​
This mode deploys and manages ClickHouse within your cluster.
ClickHouse Create Mode Configuration
clickhouse:
mode: "create"
create:
image:
repository: clickhouse/clickhouse-server
tag: "25.3.2.39"
config:
user: "clickhouse"
password: "clickhouse123"
database: "zymtrace"
service:
http:
port: 8123
native:
port: 9000
replicas: 1
resources:
requests:
cpu: "500m"
memory: "1Gi"
limits:
cpu: "2000m"
memory: "4Gi"
storage:
type: "persistent" # "persistent" or "empty_dir"
size: 30Gi
className: ""