docs/documentation/platform/audit-logs-clickhouse-setup.mdx
For high-volume audit log workloads, ClickHouse provides significant advantages over PostgreSQL:
Set the CLICKHOUSE_URL environment variable in your Infisical backend configuration:
CLICKHOUSE_URL=http(s)://username:password@host:port/database
Example:
CLICKHOUSE_URL=http://infisical:[email protected]:8123/audit_logs
That's all that's needed — ClickHouse audit log writes are enabled by default once the URL is set. To customize the table name (default: audit_logs):
CLICKHOUSE_AUDIT_LOG_TABLE_NAME=custom_audit_logs
For the full list of available ClickHouse and audit log environment variables (insert settings, table engine, disabling PostgreSQL storage, etc.), see the Environment Variables Reference.
Once CLICKHOUSE_URL is set, audit log writes switch from PostgreSQL to ClickHouse. Events are queued in a Redis stream and batch-inserted into ClickHouse every 5 seconds via a background worker. Reads also route to ClickHouse automatically. On first startup, Infisical creates the ClickHouse table if it doesn't already exist.
Recommended approach for existing deployments:
<Warning> Enabling ClickHouse is a hard cutover. All reads immediately route to ClickHouse — the application will no longer query PostgreSQL for audit logs. Any historical data that has not been migrated to ClickHouse first will be invisible in the UI until it is migrated. The data is not deleted from PostgreSQL, but the application will not read from it while ClickHouse is enabled. </Warning>Phase 1 — Migrate historical data (recommended):
Phase 2 — Enable ClickHouse:
CLICKHOUSE_URLPhase 3 — Cleanup (optional):
After configuration, verify ClickHouse integration:
If rows appear in ClickHouse, the integration is working correctly.