Lines 241-281markdown
242ClickHouse runs anywhere you can reach it over HTTP. Two common choices:
244- **[ClickHouse Cloud](https://clickhouse.com/cloud)**: Managed service with a free trial tier. Provides connection details directly compatible with `url`, `username`, and `password`.
245- **Self-hosted**: Run the official [`clickhouse/clickhouse-server`](https://hub.docker.com/r/clickhouse/clickhouse-server) container or install from the [official packages](https://clickhouse.com/docs/en/install). Suitable for VPS, dedicated hardware, or Kubernetes.
247For local development:
250docker run -d --name mastra-clickhouse \
251 -p 8123:8123 -p 9000:9000 \
252 -e CLICKHOUSE_USER=default \
253 -e CLICKHOUSE_PASSWORD=password \
254 clickhouse/clickhouse-server
258new ObservabilityStorageClickhouseVNext({
259 url: 'http://localhost:8123',
261 password: 'password',
MediumSecret Pattern
Hardcoded password in dist/docs/references/reference-storage-clickhouse.md
dist/docs/references/reference-storage-clickhouse.mdView on unpkg · L261 265## Deploying with Railway and similar platforms
267Platforms like [Railway](https://railway.com), [Fly.io](https://fly.io), [Render](https://render.com), and Heroku run application containers on ephemeral filesystems. Embedded observability backends such as DuckDB require a writable, persistent local file, so they either lose data on restart or fail to deploy entirely on these platforms.
269Use ClickHouse instead. Because ClickHouse is reached over HTTP, the same connection works from any host:
272import { Mastra } from '@mastra/core'
273import { MastraCompositeStore } from '@mastra/core/storage'
274import { PostgresStore } from '@mastra/pg'
275import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
276import { Observability, MastraStorageExporter } from '@mastra/observability'
278export const mastra = new Mastra({
279 storage: new MastraCompositeStore({
280 id: 'composite-storage',
281 default: new PostgresStore({