ClickHouse
ClickHouse is used for Mastra observability storage when the API is configured for the ClickHouse provider.
What It Owns
Section titled “What It Owns”- Local development can run
clickhouse/clickhouse-server:25.9.3.48-alpinewith theobservabilitycompose profile. apps/apiuses@mastra/clickhousefor Mastra observability storage.- Observability data is traces, logs, metrics, scores, and feedback-style runtime diagnostics, not product source-of-truth data.
Architecture Decision
Section titled “Architecture Decision”Decision: use ClickHouse as the high-volume observability backend through Mastra composite storage, while keeping application data on its owning stores.
Mastra docs recommend ClickHouse for production observability because insert-only trace export and columnar compression fit high-volume span/log workloads.
@mastra/clickhouse@1.9.0 creates v-next observability delta tables with TTL expressions over DateTime64(9, 'UTC') ingestion cursors. The local compose image must stay on a ClickHouse version that accepts DateTime64 TTL expressions.
How To Upgrade
Section titled “How To Upgrade”-
Check ClickHouse release notes and Docker tag guidance for the target server version.
-
Update
clickhouse/clickhouse-serverindocker-compose.yml. -
If the Mastra adapter changes, update
@mastra/clickhousewith the rest of the Mastra package family:Terminal window # from apps/apibun update @mastra/clickhouse -
Verify API observability:
Terminal window bun run --cwd apps/api check-typesbun run --cwd apps/api test:observability:clickhouse:smoke -
For production/customer-hosted ClickHouse, use a runbook for backup, retention, credentials, network access, and any schema migrations.
Current Limits
Section titled “Current Limits”- ClickHouse is not the default app metadata store.
- Runtime credentials should be scoped to the operations required by the observability adapter.
- Do not expose sensitive prompt, provider payload, auth, or connector data in traces.
Canonical Sources
Section titled “Canonical Sources”docker-compose.ymlapps/api/src/mastra/runtimeStorage.tsapps/api/src/env.tsapps/api/package.jsondocs/features/chat/spec.md