@mastra/clickhouse 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -3
- package/README.md +3 -2
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-clickhouse.md +300 -0
- package/dist/docs/references/reference-storage-composite.md +5 -3
- package/dist/index.cjs +581 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +581 -25
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/db/utils.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +21 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/index.d.ts +2 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/ddl.d.ts +12 -6
- package/dist/storage/domains/observability/v-next/ddl.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/feedback.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/filters.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/helpers.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +15 -4
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/metrics.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/migration.d.ts +21 -0
- package/dist/storage/domains/observability/v-next/migration.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/scores.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/tracing.d.ts +5 -1
- package/dist/storage/domains/observability/v-next/tracing.d.ts.map +1 -1
- package/dist/storage/index.d.ts +31 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,175 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
-
## 0.0.0-studio-
|
|
3
|
+
## 0.0.0-studio-cli-20260504022012
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [[`
|
|
8
|
-
- @mastra/core@0.0.0-studio-
|
|
7
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
8
|
+
- @mastra/core@0.0.0-studio-cli-20260504022012
|
|
9
|
+
|
|
10
|
+
## 1.6.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added ClickhouseStoreVNext, a ClickHouse storage adapter that uses the vNext observability domain by default. Equivalent to constructing a ClickhouseStore and overriding the observability domain manually, but exposed as a single class for new projects. ([#15984](https://github.com/mastra-ai/mastra/pull/15984))
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { Mastra } from '@mastra/core';
|
|
18
|
+
import { ClickhouseStoreVNext } from '@mastra/clickhouse';
|
|
19
|
+
|
|
20
|
+
export const mastra = new Mastra({
|
|
21
|
+
storage: new ClickhouseStoreVNext({
|
|
22
|
+
id: 'clickhouse-storage',
|
|
23
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
24
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
25
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
ClickhouseStoreVNext accepts the same configuration as ClickhouseStore and reuses the same ClickHouse client across every domain. ClickhouseStore continues to work for projects on the legacy observability schema.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`1723e09`](https://github.com/mastra-ai/mastra/commit/1723e099829892419ddbfe49287acfeac2522724), [`629f9e9`](https://github.com/mastra-ai/mastra/commit/629f9e9a7e56aa8f129515a3923c5813298790c7), [`25168fb`](https://github.com/mastra-ai/mastra/commit/25168fb9c1de9db7f8171df4f58ceb842c53aa29), [`ab34b5a`](https://github.com/mastra-ai/mastra/commit/ab34b5a2191b8e4353df1dbf7b9155e7d6628d79), [`5fb6c2a`](https://github.com/mastra-ai/mastra/commit/5fb6c2a95c1843cc231704b91354311fc1f34a71), [`2b0f355`](https://github.com/mastra-ai/mastra/commit/2b0f3553be3e9e5524da539a66e5cf82668440a4), [`394f0cf`](https://github.com/mastra-ai/mastra/commit/394f0cfc31e6b4d801219fdef2e9cc69e5bc8682), [`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`e109607`](https://github.com/mastra-ai/mastra/commit/e10960749251e34d46b480a20648c490fd30381b), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`3d7f709`](https://github.com/mastra-ai/mastra/commit/3d7f709b615e588050bb6283c4ee5cfe2978cbde), [`48a42f1`](https://github.com/mastra-ai/mastra/commit/48a42f114a4006a95e0b7a1b5ad1a24815a175c2), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006), [`2c83efc`](https://github.com/mastra-ai/mastra/commit/2c83efc4482b3efe50830e3b8b4ba9a8d219edff), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e), [`282a10c`](https://github.com/mastra-ai/mastra/commit/282a10c9446e9922afe80e10e3770481c8ac8a28), [`04151c7`](https://github.com/mastra-ai/mastra/commit/04151c7dcea934b4fe9076708a23fac161195414), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006)]:
|
|
35
|
+
- @mastra/core@1.31.0
|
|
36
|
+
|
|
37
|
+
## 1.6.0-alpha.0
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- Added ClickhouseStoreVNext, a ClickHouse storage adapter that uses the vNext observability domain by default. Equivalent to constructing a ClickhouseStore and overriding the observability domain manually, but exposed as a single class for new projects. ([#15984](https://github.com/mastra-ai/mastra/pull/15984))
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Mastra } from '@mastra/core';
|
|
45
|
+
import { ClickhouseStoreVNext } from '@mastra/clickhouse';
|
|
46
|
+
|
|
47
|
+
export const mastra = new Mastra({
|
|
48
|
+
storage: new ClickhouseStoreVNext({
|
|
49
|
+
id: 'clickhouse-storage',
|
|
50
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
51
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
52
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
ClickhouseStoreVNext accepts the same configuration as ClickhouseStore and reuses the same ClickHouse client across every domain. ClickhouseStore continues to work for projects on the legacy observability schema.
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [[`1723e09`](https://github.com/mastra-ai/mastra/commit/1723e099829892419ddbfe49287acfeac2522724), [`629f9e9`](https://github.com/mastra-ai/mastra/commit/629f9e9a7e56aa8f129515a3923c5813298790c7), [`25168fb`](https://github.com/mastra-ai/mastra/commit/25168fb9c1de9db7f8171df4f58ceb842c53aa29), [`ab34b5a`](https://github.com/mastra-ai/mastra/commit/ab34b5a2191b8e4353df1dbf7b9155e7d6628d79), [`5fb6c2a`](https://github.com/mastra-ai/mastra/commit/5fb6c2a95c1843cc231704b91354311fc1f34a71), [`394f0cf`](https://github.com/mastra-ai/mastra/commit/394f0cfc31e6b4d801219fdef2e9cc69e5bc8682), [`3d7f709`](https://github.com/mastra-ai/mastra/commit/3d7f709b615e588050bb6283c4ee5cfe2978cbde), [`48a42f1`](https://github.com/mastra-ai/mastra/commit/48a42f114a4006a95e0b7a1b5ad1a24815a175c2), [`2c83efc`](https://github.com/mastra-ai/mastra/commit/2c83efc4482b3efe50830e3b8b4ba9a8d219edff), [`282a10c`](https://github.com/mastra-ai/mastra/commit/282a10c9446e9922afe80e10e3770481c8ac8a28)]:
|
|
62
|
+
- @mastra/core@1.31.0-alpha.0
|
|
63
|
+
|
|
64
|
+
## 1.5.2
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Changed ClickHouse background task deletes to use lightweight `DELETE FROM` instead of `ALTER TABLE ... DELETE` mutations with `mutations_sync`. This makes deleted rows immediately invisible to subsequent reads without forcing part rewrites for each delete. ([#15902](https://github.com/mastra-ai/mastra/pull/15902))
|
|
69
|
+
|
|
70
|
+
Improved bulk background task deletion to push filtering into ClickHouse instead of fetching all matching task IDs into Node.js memory first. This avoids unnecessary network transfer and out-of-memory risk when deleting large result sets. As a safety guard, calling `deleteTasks` with no filters is now a no-op — use `dangerouslyClearAll` to wipe the table.
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [[`6db978c`](https://github.com/mastra-ai/mastra/commit/6db978c42e94e75540a504f7230086f0b5cd35f9), [`512a013`](https://github.com/mastra-ai/mastra/commit/512a013f285aa9c0aa8f08a35b2ce09f9938b017), [`e9becde`](https://github.com/mastra-ai/mastra/commit/e9becdeed9176b9f8392e557bde12b933f99cf7a), [`703a443`](https://github.com/mastra-ai/mastra/commit/703a44390c587d9c0b8ae94ec4edd8afb2a74044), [`808df1b`](https://github.com/mastra-ai/mastra/commit/808df1b39358b5f10b7317107e42b1fda7c87185)]:
|
|
73
|
+
- @mastra/core@1.29.1
|
|
74
|
+
|
|
75
|
+
## 1.5.2-alpha.0
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Changed ClickHouse background task deletes to use lightweight `DELETE FROM` instead of `ALTER TABLE ... DELETE` mutations with `mutations_sync`. This makes deleted rows immediately invisible to subsequent reads without forcing part rewrites for each delete. ([#15902](https://github.com/mastra-ai/mastra/pull/15902))
|
|
80
|
+
|
|
81
|
+
Improved bulk background task deletion to push filtering into ClickHouse instead of fetching all matching task IDs into Node.js memory first. This avoids unnecessary network transfer and out-of-memory risk when deleting large result sets. As a safety guard, calling `deleteTasks` with no filters is now a no-op — use `dangerouslyClearAll` to wipe the table.
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [[`703a443`](https://github.com/mastra-ai/mastra/commit/703a44390c587d9c0b8ae94ec4edd8afb2a74044), [`808df1b`](https://github.com/mastra-ai/mastra/commit/808df1b39358b5f10b7317107e42b1fda7c87185)]:
|
|
84
|
+
- @mastra/core@1.29.1-alpha.1
|
|
85
|
+
|
|
86
|
+
## 1.5.1
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Fixed `mastra dev` repeatedly reporting `MIGRATION REQUIRED` on ClickHouse Cloud after `mastra migrate` had already run successfully. The observability migration check now recognizes the engine-name variants that ClickHouse Cloud and replicated clusters use in place of `ReplacingMergeTree`. ([#15623](https://github.com/mastra-ai/mastra/pull/15623))
|
|
91
|
+
|
|
92
|
+
- Improved ClickHouse v-next observability initialization errors to include the underlying ClickHouse message in the standard error text. This makes init failures actionable in loggers that only print `error.message`. ([#15588](https://github.com/mastra-ai/mastra/pull/15588))
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [[`f112db1`](https://github.com/mastra-ai/mastra/commit/f112db179557ae9b5a0f1d25dc47f928d7d61cd9), [`21d9706`](https://github.com/mastra-ai/mastra/commit/21d970604d89eee970cbf8013d26d7551aff6ea5), [`0a0aa94`](https://github.com/mastra-ai/mastra/commit/0a0aa94729592e99885af2efb90c56aaada62247), [`ed07df3`](https://github.com/mastra-ai/mastra/commit/ed07df32a9d539c8261e892fc1bade783f5b41a6), [`01a7d51`](https://github.com/mastra-ai/mastra/commit/01a7d513493d21562f677f98550f7ceb165ba78c)]:
|
|
95
|
+
- @mastra/core@1.27.0
|
|
96
|
+
|
|
97
|
+
## 1.5.1-alpha.1
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Improved ClickHouse v-next observability initialization errors to include the underlying ClickHouse message in the standard error text. This makes init failures actionable in loggers that only print `error.message`. ([#15588](https://github.com/mastra-ai/mastra/pull/15588))
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [[`0a0aa94`](https://github.com/mastra-ai/mastra/commit/0a0aa94729592e99885af2efb90c56aaada62247), [`01a7d51`](https://github.com/mastra-ai/mastra/commit/01a7d513493d21562f677f98550f7ceb165ba78c)]:
|
|
104
|
+
- @mastra/core@1.27.0-alpha.1
|
|
105
|
+
|
|
106
|
+
## 1.5.1-alpha.0
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- Fixed `mastra dev` repeatedly reporting `MIGRATION REQUIRED` on ClickHouse Cloud after `mastra migrate` had already run successfully. The observability migration check now recognizes the engine-name variants that ClickHouse Cloud and replicated clusters use in place of `ReplacingMergeTree`. ([#15623](https://github.com/mastra-ai/mastra/pull/15623))
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [[`f112db1`](https://github.com/mastra-ai/mastra/commit/f112db179557ae9b5a0f1d25dc47f928d7d61cd9), [`21d9706`](https://github.com/mastra-ai/mastra/commit/21d970604d89eee970cbf8013d26d7551aff6ea5)]:
|
|
113
|
+
- @mastra/core@1.26.1-alpha.0
|
|
114
|
+
|
|
115
|
+
## 1.5.0
|
|
116
|
+
|
|
117
|
+
### Minor Changes
|
|
118
|
+
|
|
119
|
+
- Added unique IDs (`logId`, `metricId`, `scoreId`, `feedbackId`) to all observability signals, generated automatically at emission time for de-duplication across the framework pipeline and cross-system correlation. User-facing APIs (`logger.info()`, `metrics.emit()`, `addScore()`, `addFeedback()`) are unchanged. ([#15242](https://github.com/mastra-ai/mastra/pull/15242))
|
|
120
|
+
|
|
121
|
+
For existing ClickHouse and DuckDB observability signal tables, run `npx mastra migrate` before initializing the store so the new signal-ID schema is applied.
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Add `BackgroundTasksStorage` domain implementation so `@mastra/core` background task execution works with any storage adapter. ([#15307](https://github.com/mastra-ai/mastra/pull/15307))
|
|
126
|
+
|
|
127
|
+
- Added `getTraceLight` method to the observability storage, returning only lightweight span fields needed for timeline rendering. This avoids transferring heavy fields like `input`, `output`, `attributes`, and `metadata` when they are not needed. ([#15574](https://github.com/mastra-ai/mastra/pull/15574))
|
|
128
|
+
|
|
129
|
+
- Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`fdd54cf`](https://github.com/mastra-ai/mastra/commit/fdd54cf612a9af876e9fdd85e534454f6e7dd518), [`6315317`](https://github.com/mastra-ai/mastra/commit/63153175fe9a7b224e5be7c209bbebc01dd9b0d5), [`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`0474c2b`](https://github.com/mastra-ai/mastra/commit/0474c2b2e7c7e1ad8691dca031284841391ff1ef), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`30456b6`](https://github.com/mastra-ai/mastra/commit/30456b6b08c8fd17e109dd093b73d93b65e83bc5), [`9d11a8c`](https://github.com/mastra-ai/mastra/commit/9d11a8c1c8924eb975a245a5884d40ca1b7e0491), [`9d3b24b`](https://github.com/mastra-ai/mastra/commit/9d3b24b19407ae9c09586cf7766d38dc4dff4a69), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`62919a6`](https://github.com/mastra-ai/mastra/commit/62919a6ee0fbf3779ad21a97b1ec6696515d5104), [`d246696`](https://github.com/mastra-ai/mastra/commit/d246696139a3144a5b21b042d41c532688e957e1), [`354f9ce`](https://github.com/mastra-ai/mastra/commit/354f9ce1ca6af2074b6a196a23f8ec30012dccca), [`16e34ca`](https://github.com/mastra-ai/mastra/commit/16e34caa98b9a114b17a6125e4e3fd87f169d0d0), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`8786a61`](https://github.com/mastra-ai/mastra/commit/8786a61fa54ba265f85eeff9985ca39863d18bb6), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`1bd5104`](https://github.com/mastra-ai/mastra/commit/1bd51048b6da93507276d6623e3fd96a9e1a8944), [`e9837b5`](https://github.com/mastra-ai/mastra/commit/e9837b53699e18711b09e0ca010a4106376f2653), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`92dcf02`](https://github.com/mastra-ai/mastra/commit/92dcf029294210ac91b090900c1a0555a425c57a), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`8fb2405`](https://github.com/mastra-ai/mastra/commit/8fb2405138f2d208b7962ad03f121ca25bcc28c5), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
|
|
130
|
+
- @mastra/core@1.26.0
|
|
131
|
+
|
|
132
|
+
## 1.5.0-alpha.1
|
|
133
|
+
|
|
134
|
+
### Minor Changes
|
|
135
|
+
|
|
136
|
+
- Added unique IDs (`logId`, `metricId`, `scoreId`, `feedbackId`) to all observability signals, generated automatically at emission time for de-duplication across the framework pipeline and cross-system correlation. User-facing APIs (`logger.info()`, `metrics.emit()`, `addScore()`, `addFeedback()`) are unchanged. ([#15242](https://github.com/mastra-ai/mastra/pull/15242))
|
|
137
|
+
|
|
138
|
+
For existing ClickHouse and DuckDB observability signal tables, run `npx mastra migrate` before initializing the store so the new signal-ID schema is applied.
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Added `getTraceLight` method to the observability storage, returning only lightweight span fields needed for timeline rendering. This avoids transferring heavy fields like `input`, `output`, `attributes`, and `metadata` when they are not needed. ([#15574](https://github.com/mastra-ai/mastra/pull/15574))
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
|
|
145
|
+
- @mastra/core@1.26.0-alpha.11
|
|
146
|
+
|
|
147
|
+
## 1.4.2-alpha.0
|
|
148
|
+
|
|
149
|
+
### Patch Changes
|
|
150
|
+
|
|
151
|
+
- Add `BackgroundTasksStorage` domain implementation so `@mastra/core` background task execution works with any storage adapter. ([#15307](https://github.com/mastra-ai/mastra/pull/15307))
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [[`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c)]:
|
|
154
|
+
- @mastra/core@1.25.1-alpha.0
|
|
155
|
+
|
|
156
|
+
## 1.4.1
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Added `entityVersionId`, `parentEntityVersionId`, and `rootEntityVersionId` columns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. Added `targetType`, `targetId`, `agentVersion`, and `status` filters to `listExperiments`, and `traceId` and `status` filters to `listExperimentResults`. ([#15317](https://github.com/mastra-ai/mastra/pull/15317))
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [[`87df955`](https://github.com/mastra-ai/mastra/commit/87df955c028660c075873fd5d74af28233ce32eb), [`8fad147`](https://github.com/mastra-ai/mastra/commit/8fad14759804179c8e080ce4d9dec6ef1a808b31), [`582644c`](https://github.com/mastra-ai/mastra/commit/582644c4a87f83b4f245a84d72b9e8590585012e), [`cbdf3e1`](https://github.com/mastra-ai/mastra/commit/cbdf3e12b3d0c30a6e5347be658e2009648c130a), [`8fe46d3`](https://github.com/mastra-ai/mastra/commit/8fe46d354027f3f0f0846e64219772348de106dd), [`18c67db`](https://github.com/mastra-ai/mastra/commit/18c67dbb9c9ebc26f26f65f7d3ff836e5691ef46), [`4ba3bb1`](https://github.com/mastra-ai/mastra/commit/4ba3bb1e465ad2ddaba3bbf2bc47e0faec32985e), [`5d84914`](https://github.com/mastra-ai/mastra/commit/5d84914e0e520c642a40329b210b413fcd139898), [`8dcc77e`](https://github.com/mastra-ai/mastra/commit/8dcc77e78a5340f5848f74b9e9f1b3da3513c1f5), [`aa67fc5`](https://github.com/mastra-ai/mastra/commit/aa67fc59ee8a5eeff1f23eb05970b8d7a536c8ff), [`fd2f314`](https://github.com/mastra-ai/mastra/commit/fd2f31473d3449b6b97e837ef8641264377f41a7), [`fa8140b`](https://github.com/mastra-ai/mastra/commit/fa8140bcd4251d2e3ac85fdc5547dfc4f372b5be), [`190f452`](https://github.com/mastra-ai/mastra/commit/190f45258b0640e2adfc8219fa3258cdc5b8f071), [`e80fead`](https://github.com/mastra-ai/mastra/commit/e80fead1412cc0d1b2f7d6a1ce5017d9e0098ff7), [`0287b64`](https://github.com/mastra-ai/mastra/commit/0287b644a5c3272755cf3112e71338106664103b), [`7e7bf60`](https://github.com/mastra-ai/mastra/commit/7e7bf606886bf374a6f9d4ca9b09dd83d0533372), [`184907d`](https://github.com/mastra-ai/mastra/commit/184907d775d8609c03c26e78ccaf37315f3aa287), [`075e91a`](https://github.com/mastra-ai/mastra/commit/075e91a4549baf46ad7a42a6a8ac8dfa78cc09e6), [`0c4cd13`](https://github.com/mastra-ai/mastra/commit/0c4cd131931c04ac5405373c932a242dbe88edd6), [`b16a753`](https://github.com/mastra-ai/mastra/commit/b16a753d5748440248d7df82e29bb987a9c8386c)]:
|
|
163
|
+
- @mastra/core@1.25.0
|
|
164
|
+
|
|
165
|
+
## 1.4.1-alpha.0
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- Added `entityVersionId`, `parentEntityVersionId`, and `rootEntityVersionId` columns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. Added `targetType`, `targetId`, `agentVersion`, and `status` filters to `listExperiments`, and `traceId` and `status` filters to `listExperimentResults`. ([#15317](https://github.com/mastra-ai/mastra/pull/15317))
|
|
170
|
+
|
|
171
|
+
- Updated dependencies [[`cbdf3e1`](https://github.com/mastra-ai/mastra/commit/cbdf3e12b3d0c30a6e5347be658e2009648c130a), [`8fe46d3`](https://github.com/mastra-ai/mastra/commit/8fe46d354027f3f0f0846e64219772348de106dd), [`18c67db`](https://github.com/mastra-ai/mastra/commit/18c67dbb9c9ebc26f26f65f7d3ff836e5691ef46), [`8dcc77e`](https://github.com/mastra-ai/mastra/commit/8dcc77e78a5340f5848f74b9e9f1b3da3513c1f5), [`aa67fc5`](https://github.com/mastra-ai/mastra/commit/aa67fc59ee8a5eeff1f23eb05970b8d7a536c8ff), [`fa8140b`](https://github.com/mastra-ai/mastra/commit/fa8140bcd4251d2e3ac85fdc5547dfc4f372b5be), [`190f452`](https://github.com/mastra-ai/mastra/commit/190f45258b0640e2adfc8219fa3258cdc5b8f071), [`7e7bf60`](https://github.com/mastra-ai/mastra/commit/7e7bf606886bf374a6f9d4ca9b09dd83d0533372), [`184907d`](https://github.com/mastra-ai/mastra/commit/184907d775d8609c03c26e78ccaf37315f3aa287), [`0c4cd13`](https://github.com/mastra-ai/mastra/commit/0c4cd131931c04ac5405373c932a242dbe88edd6), [`b16a753`](https://github.com/mastra-ai/mastra/commit/b16a753d5748440248d7df82e29bb987a9c8386c)]:
|
|
172
|
+
- @mastra/core@1.25.0-alpha.3
|
|
9
173
|
|
|
10
174
|
## 1.4.0
|
|
11
175
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,9 @@ npm install @mastra/clickhouse
|
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
|
-
- Clickhouse server (version
|
|
13
|
+
- Clickhouse server (version 23.3 or higher required for delete operations; earlier versions may work for read/write operations)
|
|
14
|
+
- Lightweight `DELETE FROM` requires ClickHouse 22.8+ with `allow_experimental_lightweight_delete = 1` (for 22.8–23.2), or 23.3+ where it is generally available.
|
|
15
|
+
- The `deleteTask`, `deleteTasks`, and `deleteMessages` methods use `DELETE FROM` — ensure your server supports lightweight delete before using those operations.
|
|
14
16
|
- Node.js 22.13.0 or later
|
|
15
17
|
|
|
16
18
|
## Usage
|
|
@@ -128,7 +130,6 @@ The store uses different table engines for different types of data:
|
|
|
128
130
|
|
|
129
131
|
### Operations Not Currently Supported
|
|
130
132
|
|
|
131
|
-
- `deleteMessages(messageIds)`: Message deletion is not supported in ClickHouse
|
|
132
133
|
- AI Observability (traces/spans): Not currently supported
|
|
133
134
|
|
|
134
135
|
## Data Types
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-clickhouse
|
|
|
3
3
|
description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/clickhouse"
|
|
6
|
-
version: "0.0.0-studio-
|
|
6
|
+
version: "0.0.0-studio-cli-20260504022012"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,6 +16,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Reference
|
|
18
18
|
|
|
19
|
+
- [Reference: ClickHouse storage](references/reference-storage-clickhouse.md) - Documentation for the ClickHouse storage implementation in Mastra, including the vNext observability domain.
|
|
19
20
|
- [Reference: Composite storage](references/reference-storage-composite.md) - Documentation for combining multiple storage backends in Mastra.
|
|
20
21
|
|
|
21
22
|
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# ClickHouse storage
|
|
2
|
+
|
|
3
|
+
[ClickHouse](https://clickhouse.com/) is a columnar database designed for analytical workloads. The `@mastra/clickhouse` package provides storage adapters for several Mastra storage domains and is the recommended backend for production observability.
|
|
4
|
+
|
|
5
|
+
ClickHouse is most commonly used as the dedicated observability backend in a [composite storage](https://mastra.ai/reference/storage/composite) setup, with another database serving the remaining domains.
|
|
6
|
+
|
|
7
|
+
## When to use ClickHouse
|
|
8
|
+
|
|
9
|
+
Production observability for traces, logs, metrics, scores, and feedback.
|
|
10
|
+
|
|
11
|
+
For local development, use a composite store that combines [LibSQL](https://mastra.ai/reference/storage/libsql) (for memory and workflows) and `@mastra/duckdb` (for observability). Neither alone covers a development setup: LibSQL does not implement the observability domain, and DuckDB does not implement the other domains. See the [observability overview](https://mastra.ai/docs/observability/overview) for an example.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
**npm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @mastra/clickhouse@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**pnpm**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @mastra/clickhouse@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Yarn**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @mastra/clickhouse@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Bun**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun add @mastra/clickhouse@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You will also need a running ClickHouse server. See [Hosting options](#hosting-options) for managed and self-hosted choices.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Observability with vNext (recommended)
|
|
44
|
+
|
|
45
|
+
`ObservabilityStorageClickhouseVNext` is the current observability domain implementation. It uses an insert-only schema backed by `ReplacingMergeTree` and is optimized for the volume produced by traces, logs, metrics, scores, and feedback.
|
|
46
|
+
|
|
47
|
+
Compose it with another storage adapter so observability writes do not contend with your application data:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { Mastra } from '@mastra/core'
|
|
51
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
52
|
+
import { PostgresStore } from '@mastra/pg'
|
|
53
|
+
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
54
|
+
import { Observability, DefaultExporter } from '@mastra/observability'
|
|
55
|
+
|
|
56
|
+
const observabilityStore = new ObservabilityStorageClickhouseVNext({
|
|
57
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
58
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
59
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export const mastra = new Mastra({
|
|
63
|
+
storage: new MastraCompositeStore({
|
|
64
|
+
id: 'composite-storage',
|
|
65
|
+
default: new PostgresStore({
|
|
66
|
+
id: 'pg',
|
|
67
|
+
connectionString: process.env.DATABASE_URL!,
|
|
68
|
+
}),
|
|
69
|
+
domains: {
|
|
70
|
+
observability: observabilityStore,
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
observability: new Observability({
|
|
74
|
+
configs: {
|
|
75
|
+
default: {
|
|
76
|
+
serviceName: 'mastra',
|
|
77
|
+
exporters: [new DefaultExporter()],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`DefaultExporter` automatically selects the `insert-only` strategy when ClickHouse is the observability backend, which gives the highest write throughput. See [tracing strategies](https://mastra.ai/docs/observability/tracing/exporters/default) for details.
|
|
85
|
+
|
|
86
|
+
### Observability with the legacy domain
|
|
87
|
+
|
|
88
|
+
`ObservabilityStorageClickhouse` is the original observability adapter and remains supported for projects that have not migrated to the vNext schema. The configuration shape is the same as the vNext class.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { ObservabilityStorageClickhouse } from '@mastra/clickhouse'
|
|
92
|
+
|
|
93
|
+
const observabilityStore = new ObservabilityStorageClickhouse({
|
|
94
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
95
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
96
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
New projects should use `ObservabilityStorageClickhouseVNext` instead.
|
|
101
|
+
|
|
102
|
+
### ClickHouse for every domain
|
|
103
|
+
|
|
104
|
+
`ClickhouseStoreVNext` backs the `memory`, `workflows`, and `observability` domains with ClickHouse and uses the vNext observability adapter automatically. Use it when you want ClickHouse to back the entire application without wiring a composite store manually.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { Mastra } from '@mastra/core'
|
|
108
|
+
import { ClickhouseStoreVNext } from '@mastra/clickhouse'
|
|
109
|
+
|
|
110
|
+
export const mastra = new Mastra({
|
|
111
|
+
storage: new ClickhouseStoreVNext({
|
|
112
|
+
id: 'clickhouse-storage',
|
|
113
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
114
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
115
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
116
|
+
}),
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`ClickhouseStoreVNext` accepts the same configuration as `ClickhouseStore` and reuses the same ClickHouse client across every domain.
|
|
121
|
+
|
|
122
|
+
#### Manual composition
|
|
123
|
+
|
|
124
|
+
`ClickhouseStore` is the long-standing class that backs every domain with the legacy observability adapter. New projects should prefer `ClickhouseStoreVNext`. If you need to customize the composite (for example, to override one domain with a different backend), build it manually:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { Mastra } from '@mastra/core'
|
|
128
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
129
|
+
import { ClickhouseStore, ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
130
|
+
|
|
131
|
+
const credentials = {
|
|
132
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
133
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
134
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const mastra = new Mastra({
|
|
138
|
+
storage: new MastraCompositeStore({
|
|
139
|
+
id: 'composite-storage',
|
|
140
|
+
default: new ClickhouseStore({ id: 'clickhouse-storage', ...credentials }),
|
|
141
|
+
domains: {
|
|
142
|
+
observability: new ObservabilityStorageClickhouseVNext(credentials),
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Bring your own ClickHouse client
|
|
149
|
+
|
|
150
|
+
Pass a pre-configured client when you need custom connection settings such as request timeouts, compression, or interceptors:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { createClient } from '@clickhouse/client'
|
|
154
|
+
import { ClickhouseStore } from '@mastra/clickhouse'
|
|
155
|
+
|
|
156
|
+
const client = createClient({
|
|
157
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
158
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
159
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
160
|
+
request_timeout: 60_000,
|
|
161
|
+
compression: { request: true, response: true },
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
const storage = new ClickhouseStore({ id: 'clickhouse-storage', client })
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The same `client` form is accepted by `ObservabilityStorageClickhouse` and `ObservabilityStorageClickhouseVNext`.
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
### `ClickhouseStore` options
|
|
172
|
+
|
|
173
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
174
|
+
|
|
175
|
+
**url** (`string`): ClickHouse server URL (for example, \`https\://your-instance.clickhouse.cloud:8443\` or \`http\://localhost:8123\`). Required when not passing a pre-configured \`client\`.
|
|
176
|
+
|
|
177
|
+
**username** (`string`): ClickHouse username. Required when not passing a pre-configured \`client\`.
|
|
178
|
+
|
|
179
|
+
**password** (`string`): ClickHouse password. Required when not passing a pre-configured \`client\`. It can be an empty string for the default user on a local instance.
|
|
180
|
+
|
|
181
|
+
**client** (`ClickHouseClient`): Pre-configured ClickHouse client from \`@clickhouse/client\`. Use this when you need custom request settings. Mutually exclusive with the credential fields above.
|
|
182
|
+
|
|
183
|
+
**ttl** (`object`): Per-table TTL configuration applied at table creation time. Accepts row-level and column-level TTLs in interval units from \`NANOSECOND\` through \`YEAR\`.
|
|
184
|
+
|
|
185
|
+
**disableInit** (`boolean`): When \`true\`, the store does not run table creation or migrations on first use. Call \`storage.init()\` explicitly from your deployment scripts. (Default: `false`)
|
|
186
|
+
|
|
187
|
+
`ClickhouseStore` also accepts every option from `ClickHouseClientConfigOptions` (such as `database`, `request_timeout`, `compression`, `keep_alive`, and `max_open_connections`).
|
|
188
|
+
|
|
189
|
+
### Observability domain options
|
|
190
|
+
|
|
191
|
+
`ObservabilityStorageClickhouse` and `ObservabilityStorageClickhouseVNext` accept the same connection options as `ClickhouseStore` (`url`, `username`, `password`, or a pre-configured `client`).
|
|
192
|
+
|
|
193
|
+
## Hosting options
|
|
194
|
+
|
|
195
|
+
ClickHouse runs anywhere you can reach it over HTTP. Two common choices:
|
|
196
|
+
|
|
197
|
+
- **[ClickHouse Cloud](https://clickhouse.com/cloud)**: Managed service with a free trial tier. Provides connection details directly compatible with `url`, `username`, and `password`.
|
|
198
|
+
- **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.
|
|
199
|
+
|
|
200
|
+
For local development:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
docker run -d --name mastra-clickhouse \
|
|
204
|
+
-p 8123:8123 -p 9000:9000 \
|
|
205
|
+
-e CLICKHOUSE_USER=default \
|
|
206
|
+
-e CLICKHOUSE_PASSWORD=password \
|
|
207
|
+
clickhouse/clickhouse-server
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
new ObservabilityStorageClickhouseVNext({
|
|
212
|
+
url: 'http://localhost:8123',
|
|
213
|
+
username: 'default',
|
|
214
|
+
password: 'password',
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Deploying with Railway and similar platforms
|
|
219
|
+
|
|
220
|
+
Platforms 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.
|
|
221
|
+
|
|
222
|
+
Use ClickHouse instead. Because ClickHouse is reached over HTTP, the same connection works from any host:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { Mastra } from '@mastra/core'
|
|
226
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
227
|
+
import { PostgresStore } from '@mastra/pg'
|
|
228
|
+
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
229
|
+
import { Observability, DefaultExporter } from '@mastra/observability'
|
|
230
|
+
|
|
231
|
+
export const mastra = new Mastra({
|
|
232
|
+
storage: new MastraCompositeStore({
|
|
233
|
+
id: 'composite-storage',
|
|
234
|
+
default: new PostgresStore({
|
|
235
|
+
id: 'pg',
|
|
236
|
+
connectionString: process.env.DATABASE_URL!,
|
|
237
|
+
}),
|
|
238
|
+
domains: {
|
|
239
|
+
observability: new ObservabilityStorageClickhouseVNext({
|
|
240
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
241
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
242
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
243
|
+
}),
|
|
244
|
+
},
|
|
245
|
+
}),
|
|
246
|
+
observability: new Observability({
|
|
247
|
+
configs: {
|
|
248
|
+
default: {
|
|
249
|
+
serviceName: 'mastra',
|
|
250
|
+
exporters: [new DefaultExporter()],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}),
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Two ways to provision the database:
|
|
258
|
+
|
|
259
|
+
- **Managed**: Use ClickHouse Cloud. Set `CLICKHOUSE_URL`, `CLICKHOUSE_USERNAME`, and `CLICKHOUSE_PASSWORD` as environment variables in your hosting platform.
|
|
260
|
+
- **Self-hosted on Railway**: Add a ClickHouse service to your Railway project from the official Docker image, then reference it in the application service through Railway's private networking.
|
|
261
|
+
|
|
262
|
+
The same approach applies to other hosts with ephemeral filesystems. For application data that should also live off-host, pair this setup with a managed PostgreSQL or LibSQL/Turso instance for the `default` storage.
|
|
263
|
+
|
|
264
|
+
> **Warning:** Do not point an embedded backend like DuckDB at a path inside an ephemeral container filesystem. Data written there is lost when the container restarts, and on some platforms the path is read-only.
|
|
265
|
+
|
|
266
|
+
## Initialization
|
|
267
|
+
|
|
268
|
+
When passed to the `Mastra` class, `ClickhouseStore` calls `init()` automatically to create the schema and run any pending migrations. The same applies to `ObservabilityStorageClickhouseVNext` when used through `MastraCompositeStore`.
|
|
269
|
+
|
|
270
|
+
If you manage storage outside of `Mastra`, call `init()` explicitly:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
274
|
+
|
|
275
|
+
const observability = new ObservabilityStorageClickhouseVNext({
|
|
276
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
277
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
278
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
await observability.init()
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
In CI/CD pipelines, set `disableInit: true` on `ClickhouseStore` and run `init()` from a deployment step that uses elevated credentials. Runtime application credentials can then be limited to read and insert.
|
|
285
|
+
|
|
286
|
+
## Observability
|
|
287
|
+
|
|
288
|
+
ClickHouse is the recommended backend for production observability:
|
|
289
|
+
|
|
290
|
+
- **Insert-only strategy**: `DefaultExporter` writes completed spans in batches without per-span updates, which is the highest-throughput strategy available.
|
|
291
|
+
- **Columnar compression**: Span attributes and log payloads compress well compared to the same data in row-oriented databases.
|
|
292
|
+
|
|
293
|
+
For the full strategy matrix and production guidance, see the [`DefaultExporter` reference](https://mastra.ai/docs/observability/tracing/exporters/default).
|
|
294
|
+
|
|
295
|
+
## Related
|
|
296
|
+
|
|
297
|
+
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
298
|
+
- [Composite storage](https://mastra.ai/reference/storage/composite)
|
|
299
|
+
- [`DefaultExporter`](https://mastra.ai/docs/observability/tracing/exporters/default)
|
|
300
|
+
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
@@ -218,12 +218,12 @@ const storage = new MastraCompositeStore({
|
|
|
218
218
|
|
|
219
219
|
Observability data can quickly overwhelm general-purpose databases in production. A single agent interaction can generate hundreds of spans, and high-traffic applications can produce thousands of traces per day.
|
|
220
220
|
|
|
221
|
-
**ClickHouse** is recommended for production observability because it's optimized for high-volume, write-heavy analytics workloads. Use composite storage to route observability to ClickHouse while keeping other data in your primary database:
|
|
221
|
+
**[ClickHouse](https://mastra.ai/reference/storage/clickhouse)** is recommended for production observability because it's optimized for high-volume, write-heavy analytics workloads. Use composite storage to route observability to ClickHouse while keeping other data in your primary database:
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
224
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
225
225
|
import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
|
|
226
|
-
import {
|
|
226
|
+
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
227
227
|
|
|
228
228
|
const storage = new MastraCompositeStore({
|
|
229
229
|
id: 'composite',
|
|
@@ -231,7 +231,7 @@ const storage = new MastraCompositeStore({
|
|
|
231
231
|
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
232
232
|
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
233
233
|
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
234
|
-
observability: new
|
|
234
|
+
observability: new ObservabilityStorageClickhouseVNext({
|
|
235
235
|
url: process.env.CLICKHOUSE_URL,
|
|
236
236
|
username: process.env.CLICKHOUSE_USERNAME,
|
|
237
237
|
password: process.env.CLICKHOUSE_PASSWORD,
|
|
@@ -240,4 +240,6 @@ const storage = new MastraCompositeStore({
|
|
|
240
240
|
})
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
+
> **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that have not migrated. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
|
|
244
|
+
|
|
243
245
|
> **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [DefaultExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/default) for the full list of supported providers.
|