ClickHouse

Datafly Signal delivers events to ClickHouse for real-time analytics, high-performance columnar storage, and sub-second query response times on billions of rows.

Prerequisites

Before configuring ClickHouse in Signal, you need a ClickHouse server (self-hosted or ClickHouse Cloud) with a database and a MergeTree table.

Set Up a ClickHouse Server

You have two options:

Option A: ClickHouse Cloud (Managed)

  1. Sign up at clickhouse.cloud.
  2. Create a new service and select a region.
  3. Note the Host (e.g. abc123.us-east-1.aws.clickhouse.cloud), Port (default 8443 for HTTPS), and the default Username and Password.

Option B: Self-Hosted

  1. Install ClickHouse using the official guide.
  2. Ensure the HTTP(S) interface is enabled (default port 8443 for HTTPS, 8123 for HTTP).
  3. Note the hostname and port.

Create a Database

Connect to ClickHouse and create a database:

CREATE DATABASE IF NOT EXISTS datafly_events;

Create a MergeTree Table

Create a table using the MergeTree engine family for optimal analytics performance:

CREATE TABLE datafly_events.events (
  event_id String,
  type LowCardinality(String),
  event String,
  anonymous_id String,
  user_id String,
  timestamp DateTime64(3),
  received_at DateTime64(3),
  sent_at DateTime64(3),
  context String,
  properties String,
  traits String,
  source_id String,
  integration_id String
)
ENGINE = MergeTree()
ORDER BY (type, timestamp)
PARTITION BY toYYYYMM(timestamp);

The ORDER BY clause defines the primary sort key and determines the primary index. Ordering by (type, timestamp) optimises queries that filter by event type and time range. LowCardinality(String) improves performance for columns with few unique values.

Create a User for Signal

For self-hosted ClickHouse, create a dedicated user:

CREATE USER datafly_signal IDENTIFIED BY 'your_secure_password';
GRANT INSERT ON datafly_events.events TO datafly_signal;

For ClickHouse Cloud, you can use the default user or create an additional user in the Cloud console.

Configuration

FieldTypeRequiredDescription
hoststringYesThe ClickHouse server hostname.
portstringYesThe ClickHouse HTTP(S) port. Defaults to 8443 (HTTPS) or 8123 (HTTP).
databasestringYesThe target database name.
tablestringYesThe target table name to insert rows into.
usernamestringYesThe ClickHouse username for authentication.
passwordsecretYesThe ClickHouse password for authentication.
use_tlsbooleanNoEnable TLS for the connection. Defaults to true.

Signal Setup

Quick Setup

  1. Navigate to Integrations in the sidebar.
  2. Open the Integration Library tab.
  3. Find ClickHouse or filter by Cloud Storage.
  4. Click Install, select a variant if available, and fill in the required fields.
  5. Click Install Integration to create the integration with a ready-to-use default blueprint.

API Setup

curl -X POST http://localhost:8084/v1/admin/integration-catalog/clickhouse/install \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ClickHouse",
    "variant": "default",
    "config": {
      "host": "abc123.us-east-1.aws.clickhouse.cloud",
      "port": "8443",
      "database": "datafly_events",
      "table": "events",
      "username": "datafly_signal",
      "password": "your_secure_password",
      "use_tls": true
    },
    "delivery_mode": "server_side"
  }'

Testing

  1. Enable the integration in Signal and trigger a test event on your website.
  2. Connect to ClickHouse and query the target table:
SELECT * FROM datafly_events.events ORDER BY timestamp DESC LIMIT 10;
  1. Verify that event rows are appearing with correct data.
  2. In Signal, check the Live Events view to confirm delivery status shows as successful.

Troubleshooting

ProblemSolution
Events not appearing in ClickHouseVerify the host, port, database, and table name are correct.
Connection refused / timeoutCheck that the ClickHouse server is running and the HTTP(S) port is accessible. Verify firewall rules or ClickHouse Cloud IP access list.
Authentication failedThe username or password is incorrect. Verify the credentials.
Table not foundThe table does not exist in the specified database. Verify the database and table names.
INSERT permission deniedThe user lacks INSERT permission. Run GRANT INSERT ON db.table TO user;.
TLS errorsIf use_tls is true, the port should be 8443. If false, use 8123. ClickHouse Cloud always requires TLS.
Slow insertsClickHouse performs best with batch inserts. Increase the batch size in the integration settings. Avoid inserting one row at a time.
Schema mismatchThe column types must match the event data. Verify column types with DESCRIBE TABLE datafly_events.events;.

Visit ClickHouse documentation for full SQL reference, table engine options, and performance tuning guides.