Prerequisites
- If your ClickHouse security posture requires IP whitelisting, have the data-syncing service’s static IP available. You need it in Step 1.
🚧 SSH tunneling not supported ClickHouse destinations don’t support SSH tunneling. Your ClickHouse instance must be accessible over the public internet.
Step 1: Allow access
Create a rule in a security group or firewall settings to whitelist:- Incoming connections to your host and port (usually
9440for TLS or9000for TCP) from the static IP. - Outbound connections from ports
1024to65535to the static IP.
📘 Network allowlistingIf private-cloud or self-hosted, contact your Metronome representative for the static egress IP.
- Cloud Hosted (US):
35.192.85.117/32- Cloud Hosted (EU):
104.199.49.149/32
Step 2: Create writer user
Create a database user to write the exported data.- Open a connection to your ClickHouse database.
- Run the following SQL command to create a user for the data transfer:
🚧 Password rules Passwords can only include alphanumeric characters (A-Z,a-z,0-9), dashes (-), and underscores (_).
- Grant the user required privileges on the database:
📘 Understanding theCREATE TEMPORARY TABLEandS3permissions The data-syncing service uses these permissions to efficiently transfer data to ClickHouse. It stages data in object storage as compressed files, copies it into temporary tables withCOPY INTO, and merges it into the target tables. The temporary table doesn’t persist beyond the session.
Step 3: Set up staging bucket
ClickHouse destinations require a staging bucket to efficiently transfer data. Configure your staging bucket using one of the following options:- S3 — Follow the S3 staging bucket setup guide.
- GCS — Follow the GCS staging bucket setup guide.
- Implicit — Use your ClickHouse cluster’s built-in staging resources (see below).
📘 Using the implicit bucket option ClickHouse supports configuring staging resources with environment credentials. If this setting is enabled on your ClickHouse cluster, you can choose the implicit option during destination setup to use the cluster’s configured staging resources.
📘 Optional: Add a short retention lifecycle policy If using S3 or GCS for staging, you can configure a lifecycle rule on the bucket to automatically delete objects older than 2 days. Transfer logic cleans up files after completion, so this step is optional.
Step 4: Add your destination
🚧 Connection protocol
Use the ClickHouse TCP native protocol, not HTTPS. This is commonly exposed on port 9000.
Use the following details to complete the connection setup:
- Host name
- Port
- Cluster
- Database name
- Schema name
- Username
- Password
- Staging bucket details
📘 Understanding the database vs. schema fields Depending on the version of your integration, the setup asks for both a database and schema, or a connection database and write database.These can be the same value, but don’t need to be.
- Database (also referred to as
connection_database): the database used to establish the connection with ClickHouse.- Schema (also referred to as
write_database): the database or schema where the service writes data.
Querying ClickHouse data
The resulting ClickHouse tables use the ReplacingMergeTree table engine to efficiently upsert changes. Use theFINAL keyword when selecting from these tables to remove duplicates.