Skip to content

Commit f54955c

Browse files
authored
Merge pull request #4033 from ClickHouse/clickstack-json
Docs for JSON in ClickStack
2 parents 63e69d3 + f342383 commit f54955c

File tree

11 files changed

+488
-3
lines changed

11 files changed

+488
-3
lines changed

docs/use-cases/observability/clickstack/config.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ For example, below is the Logs source configured with correlated sources:
336336
- Useful for development and testing
337337
- Disable in production
338338

339+
- `BETA_CH_OTEL_JSON_SCHEMA_ENABLED`
340+
- **Default:** `false`
341+
- **Description:** Enables Beta support for the JSON type in HyperDX. See also [`OTEL_AGENT_FEATURE_GATE_ARG`](#otel-collector) to enable JSON support in the OTel collector.
342+
- **Guidance:**
343+
- Set to `true` to enable JSON support in ClickStack.
344+
339345

340346
## OpenTelemetry collector {#otel-collector}
341347

@@ -383,6 +389,12 @@ See ["ClickStack OpenTelemetry Collector"](/use-cases/observability/clickstack/i
383389
- Set if using a custom database name
384390
- Ensure the specified user has access to this database
385391

392+
- `OTEL_AGENT_FEATURE_GATE_ARG`
393+
- **Default:** `<empty string>`
394+
- **Description:** Enables feature flags to enabled in the collector. If set to `--feature-gates=clickhouse.json` enables Beta support for the JSON type in collector, ensuring schemas are created with the type. See also [`BETA_CH_OTEL_JSON_SCHEMA_ENABLED`](#hyperdx) to enable JSON support in HyperDX.
395+
- **Guidance:**
396+
- Set to `true` to enable JSON support in ClickStack.
397+
386398
## ClickHouse {#clickhouse}
387399

388400
ClickStack ships with a default ClickHouse configuration designed for multi-terabyte scale, but users are free to modify and optimize it to suit their workload.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import BetaBadge from '@theme/badges/BetaBadge';
2+
3+
## JSON type support {#json-type-support}
4+
5+
<BetaBadge/>
6+
7+
ClickStack has beta support for the [JSON type](/interfaces/formats/JSON) from version `2.0.4`.
8+
9+
For the benefits of this type see [Benefits of the JSON type](/use-cases/observability/clickstack/ingesting-data/otel-collector#benefits-json-type).
10+
11+
In order to enable support for the JSON type users must set the following environment variables:
12+
13+
- `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'` - enables support in the OTel collector, ensuring schemas are created using the JSON type.
14+
- `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` - enables support in the HyperDX application, allowing JSON data to be queried.
15+

docs/use-cases/observability/clickstack/deployment/all-in-one.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sidebar_position: 0
77
description: 'Deploying ClickStack with All In One - The ClickHouse Observability Stack'
88
---
99

10+
import JSONSupport from '@site/docs/use-cases/observability/clickstack/deployment/_snippets/_json_support.md';
1011
import Image from '@theme/IdealImage';
1112
import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png';
1213
import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png';
@@ -112,3 +113,11 @@ On connecting to the HyperDX UI, navigate to [`Team Settings`](http://localhost:
112113
## Configuring the OpenTelemetry collector {#configuring-collector}
113114

114115
The OTel collector configuration can be modified if required - see ["Modifying configuration"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration).
116+
117+
<JSONSupport/>
118+
119+
For example:
120+
121+
```shell
122+
docker run -e OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json' -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one
123+
```

docs/use-cases/observability/clickstack/deployment/docker-compose.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ sidebar_position: 2
77
description: 'Deploying ClickStack with Docker Compose - The ClickHouse Observability Stack'
88
---
99

10+
1011
import Image from '@theme/IdealImage';
1112
import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png';
1213
import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png';
14+
import JSONSupport from '@site/docs/use-cases/observability/clickstack/deployment/_snippets/_json_support.md';
1315

1416
All ClickStack components are distributed separately as individual Docker images:
1517

@@ -150,3 +152,29 @@ This distribution can be used with ClickHouse Cloud. Users should:
150152
The `CLICKHOUSE_ENDPOINT` should be the ClickHouse Cloud HTTPS endpoint, including the port `8443` e.g. `https://mxl4k3ul6a.us-east-2.aws.clickhouse.com:8443`
151153

152154
- On connecting to the HyperDX UI and creating a connection to ClickHouse, use your Cloud credentials.
155+
156+
<JSONSupport/>
157+
158+
To set these, modify the relevant services in the `docker-compose.yaml`:
159+
160+
161+
```yaml
162+
app:
163+
image: ${HDX_IMAGE_REPO}/${IMAGE_NAME_DOCKERHUB}:${IMAGE_VERSION}
164+
ports:
165+
- ${HYPERDX_API_PORT}:${HYPERDX_API_PORT}
166+
- ${HYPERDX_APP_PORT}:${HYPERDX_APP_PORT}
167+
environment:
168+
BETA_CH_OTEL_JSON_SCHEMA_ENABLED: true # enable JSON
169+
FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT}
170+
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
171+
HYPERDX_API_PORT: ${HYPERDX_API_PORT}
172+
# truncated for brevity
173+
174+
otel-collector:
175+
image: ${HDX_IMAGE_REPO}/${OTEL_COLLECTOR_IMAGE_NAME_DOCKERHUB}:${IMAGE_VERSION}
176+
environment:
177+
OTEL_AGENT_FEATURE_GATE_ARG: '--feature-gates=clickhouse.json' # enable JSON
178+
CLICKHOUSE_ENDPOINT: 'tcp://ch-server:9000?dial_timeout=10s'
179+
# truncated for brevity
180+
```

docs/use-cases/observability/clickstack/deployment/helm.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ description: 'Deploying ClickStack with Helm - The ClickHouse Observability Stac
1010
import Image from '@theme/IdealImage';
1111
import hyperdx_24 from '@site/static/images/use-cases/observability/hyperdx-24.png';
1212
import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png';
13+
import JSONSupport from '@site/docs/use-cases/observability/clickstack/deployment/_snippets/_json_support.md';
1314

1415
The helm chart for HyperDX can be found [here](https://github.com/hyperdxio/helm-charts) and is the **recommended** method for production deployments.
1516

@@ -219,6 +220,18 @@ clickhouse:
219220
220221
otel:
221222
clickhouseEndpoint: ${CLICKHOUSE_URL}
223+
224+
hyperdx:
225+
defaultConnections: |
226+
[
227+
{
228+
"name": "External ClickHouse",
229+
"host": "http://your-clickhouse-server:8123",
230+
"port": 8123,
231+
"username": "your-username",
232+
"password": "your-password"
233+
}
234+
]
222235
```
223236

224237
```shell
@@ -291,3 +304,33 @@ helm install my-hyperdx hyperdx/hdx-oss-v2 --debug --dry-run
291304
```shell
292305
kubectl get pods -l app.kubernetes.io/name=hdx-oss-v2
293306
```
307+
308+
<JSONSupport/>
309+
310+
Users can set these environment variables via either parameters or the `values.yaml` e.g.
311+
312+
313+
*values.yaml*
314+
315+
```yaml
316+
hyperdx:
317+
...
318+
env:
319+
- name: BETA_CH_OTEL_JSON_SCHEMA_ENABLED
320+
value: "true"
321+
322+
otel:
323+
...
324+
env:
325+
- name: OTEL_AGENT_FEATURE_GATE_ARG
326+
value: "--feature-gates=clickhouse.json"
327+
```
328+
329+
or via `--set`:
330+
331+
```shell
332+
helm install myrelease hyperdx-helm --set "hyperdx.env[0].name=BETA_CH_OTEL_JSON_SCHEMA_ENABLED" \
333+
--set "hyperdx.env[0].value=true" \
334+
--set "otel.env[0].name=OTEL_AGENT_FEATURE_GATE_ARG" \
335+
--set "otel.env[0].value=--feature-gates=clickhouse.json"
336+
```

docs/use-cases/observability/clickstack/deployment/hyperdx-only.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Image from '@theme/IdealImage';
1111
import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png';
1212
import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png';
1313
import hyperdx_2 from '@site/static/images/use-cases/observability/hyperdx-2.png';
14+
import JSONSupport from '@site/docs/use-cases/observability/clickstack/deployment/_snippets/_json_support.md';
1415

1516
This option is designed for users who already have a running ClickHouse instance populated with observability or event data.
1617

@@ -71,3 +72,11 @@ Users can modify the [Docker Compose configuration](/use-cases/observability/cli
7172
Even if you are managing your own OpenTelemetry collector, independent of the other components in the stack, we still recommend using the ClickStack distribution of the collector. This ensures the default schema is used and best practices for ingestion are applied.
7273

7374
For details on deploying and configuring a standalone collector see ["Ingesting with OpenTelemetry"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration).
75+
76+
<JSONSupport/>
77+
78+
For the HyperDX-only image, users only need to set the `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` parameter e.g.
79+
80+
```shell
81+
docker run -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -e MONGO_URI=mongodb://YOUR_MONGODB_URI -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx
82+
```

docs/use-cases/observability/clickstack/deployment/local-mode-only.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: 'Deploying ClickStack with Local Mode Only - The ClickHouse Observa
1010
import Image from '@theme/IdealImage';
1111
import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png';
1212
import hyperdx_2 from '@site/static/images/use-cases/observability/hyperdx-2.png';
13-
13+
import JSONSupport from '@site/docs/use-cases/observability/clickstack/deployment/_snippets/_json_support.md';
1414

1515
Similar to the [all-in-one image](/use-cases/observability/clickstack/deployment/docker-compose), this comprehensive Docker image bundles all ClickStack components:
1616

@@ -55,3 +55,12 @@ Create a source, retain all default values, and complete the `Table` field with
5555
<Image img={hyperdx_logs} alt="Create logs source" size="md"/>
5656

5757
</VerticalStepper>
58+
59+
60+
<JSONSupport/>
61+
62+
For the local mode only image, users only need to set the `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` parameter e.g.
63+
64+
```shell
65+
docker run -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx-local
66+
```

docs/use-cases/observability/clickstack/example-datasets/remote-demo-data.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ import demo_sources from '@site/static/images/use-cases/observability/hyperdx-de
3939
import edit_connection from '@site/static/images/use-cases/observability/edit_connection.png';
4040

4141

42-
**The following guide assumes you have deployed ClickStack using the [instructions for the all-in-one image](/use-cases/observability/clickstack/getting-started), or [Local Mode Only](/use-cases/observability/clickstack/deployment/local-mode-only) and completed initial user creation.**
42+
**The following guide assumes you have deployed ClickStack using the [instructions for the all-in-one image](/use-cases/observability/clickstack/getting-started), or [Local Mode Only](/use-cases/observability/clickstack/deployment/local-mode-only) and completed initial user creation. Alternatively, users can skip all local setup and simply connect to our ClickStack hosted demo [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com) which uses this dataset.**
4343

44-
This getting started guide uses a dataset available on the demo server that users can access when first deploying HyperDX. The dataset is hosted on the public ClickHouse instance at [sql.clickhouse.com](https://sql.clickhouse.com).
44+
This guide uses a sample dataset hosted on the public ClickHouse playground at [sql.clickhouse.com](https://sql.clickhpouse.com), which you can connect to from your local ClickStack deployment.
4545

4646
It contains approximately 40 hours of data captured from the ClickHouse version of the official OpenTelemetry (OTel) demo. The data is replayed nightly with timestamps adjusted to the current time window, allowing users to explore system behavior using HyperDX's integrated logs, traces, and metrics.
4747

docs/use-cases/observability/clickstack/ingesting-data/collector.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ title: 'ClickStack OpenTelemetry Collector'
88
---
99

1010
import Image from '@theme/IdealImage';
11+
import BetaBadge from '@theme/badges/BetaBadge';
1112
import observability_6 from '@site/static/images/use-cases/observability/observability-6.png';
1213
import observability_8 from '@site/static/images/use-cases/observability/observability-8.png';
1314
import clickstack_with_gateways from '@site/static/images/use-cases/observability/clickstack-with-gateways.png';
@@ -291,3 +292,88 @@ For agent instances responsible for shipping events to a gateway, and only setti
291292
| 1k/second | 0.2CPU, 0.2GiB |
292293
| 5k/second | 0.5 CPU, 0.5GiB |
293294
| 10k/second | 1 CPU, 1GiB |
295+
296+
## JSON support {#json-support}
297+
298+
<BetaBadge/>
299+
300+
ClickStack has beta support for the [JSON type](/interfaces/formats/JSON) from version `2.0.4`.
301+
302+
### Benefits of the JSON type {#benefits-json-type}
303+
304+
The JSON type offers the following benefits to ClickStack users:
305+
306+
- **Type preservation** - Numbers stay numbers, booleans stay booleans—no more flattening everything into strings. This means fewer casts, simpler queries, and more accurate aggregations.
307+
- **Path-level columns** - Each JSON path becomes its own sub-column, reducing I/O. Queries only read the fields they need, unlocking major performance gains over the old Map type which required the entire column to be read in order to query a specific field.
308+
- **Deep nesting just works** - Naturally handle complex, deeply nested structures without manual flattening (as required by the Map type) and subsequent awkward JSONExtract functions.
309+
- **Dynamic, evolving schemas** - Perfect for observability data where teams add new tags and attributes over time. JSON handles these changes automatically, without schema migrations.
310+
- **Faster queries, lower memory** - Typical aggregations over attributes like `LogAttributes` see 5-10x less data read and dramatic speedups, cutting both query time and peak memory usage.
311+
- **Simple management** - No need to pre-materialize columns for performance. Each field becomes its own sub-column, delivering the same speed as native ClickHouse columns.
312+
313+
### Enabling JSON support {#enabling-json-support}
314+
315+
To enable this support for the collector, set the environment variable `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'` on any deployment that includes the collector. This ensures the schemas are created in ClickHouse using the JSON type.
316+
317+
:::note HyperDX support
318+
In order to query the JSON type, support must also be enabled in the HyperDX application layer via the environment variable `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true`.
319+
:::
320+
321+
For example:
322+
323+
```shell
324+
docker run -e OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json' -e OPAMP_SERVER_URL=${OPAMP_SERVER_URL} -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-otel-collector
325+
```
326+
327+
### Migrating from map-based schemas to the JSON type {#migrating-from-map-based-schemas-to-json}
328+
329+
:::important Backwards compatibility
330+
The [JSON type](/interfaces/formats/JSON) type is not backwards compatible with existing map-based schemas. New tables will be created using the `JSON` type.
331+
:::
332+
333+
334+
To migrate from the Map-based schemas, follow these steps:
335+
336+
<VerticalStepper headerLevel="h4">
337+
338+
339+
#### Stop the OTel collector {#stop-the-collector}
340+
341+
#### Rename existing tables and update sources {#rename-existing-tables-sources}
342+
343+
Rename existing tables and update data sources in HyperDX.
344+
345+
For example:
346+
347+
```sql
348+
RENAME TABLE otel_logs TO otel_logs_map;
349+
RENAME TABLE otel_metrics TO otel_metrics_map;
350+
```
351+
352+
#### Deploy the collector {#deploy-the-collector}
353+
354+
Deploy the collector with `OTEL_AGENT_FEATURE_GATE_ARG` set.
355+
356+
#### Restart the HyperDX container with JSON schema support {#restart-the-hyperdx-container}
357+
358+
```shell
359+
export BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true
360+
```
361+
362+
#### Create new data sources {#create-new-data-sources}
363+
364+
Create new data sources in HyperDX pointing to the JSON tables.
365+
366+
</VerticalStepper>
367+
368+
#### Migrating existing data (optional) {#migrating-existing-data}
369+
370+
To move old data into the new JSON tables:
371+
372+
```sql
373+
INSERT INTO otel_logs SELECT * FROM otel_logs_map;
374+
INSERT INTO otel_metrics SELECT * FROM otel_metrics_map;
375+
```
376+
377+
:::warning
378+
Recommended only for datasets smaller than ~10 billion rows. Data previously stored with the Map type did not preserve type precision (all values were strings). As a result, this old data will appear as strings in the new schema until it ages out, requiring some casting on the frontend. Type for new data will be preserved with the JSON type.
379+
:::

0 commit comments

Comments
 (0)