Skip to content

Commit 52ca182

Browse files
MikeShi42teeohhem
andauthored
feat: Add ClickHouse JSON Type Support (#969)
- Upgrades ClickHouse to 25.6, fixes breaking config change, needed for latest JSON type - Upgrades OTel Collector to 0.129.1, fixes breaking config change, needed for latest JSON support in exporter - Upgrades OTel OpAMP Supervisor to 0.128.0 - Fixes features to support JSON type columns in OTel in HyperDX (filtering, searching, graphing, opening rows, etc.) Requires users to set `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` in `ch-server` and `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'` in `otel-collector` to enable JSON schema. Users must start a new ClickHouse DB or migrate their own table manually to enable as it is not schema compatible and migration is not automatic. Closes HDX-1849, HDX-1969, HDX-1849, HDX-1966, HDX-1964 Co-authored-by: Tom Alexander <3245235+teeohhem@users.noreply.github.com>
1 parent 8fb3db3 commit 52ca182

19 files changed

+127
-25
lines changed

.changeset/heavy-pets-walk.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/api": patch
4+
"@hyperdx/app": patch
5+
---
6+
7+
feat: Add ClickHouse JSON Type Support

docker-compose.ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
depends_on:
2323
- ch-server
2424
ch-server:
25-
image: clickhouse/clickhouse-server:24-alpine
25+
image: clickhouse/clickhouse-server:25.6-alpine
2626
environment:
2727
# default settings
2828
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1

docker-compose.dev.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ services:
3030
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
3131
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
3232
OPAMP_SERVER_URL: 'http://host.docker.internal:${HYPERDX_OPAMP_PORT}'
33+
# Uncomment to enable stdout logging for the OTel collector
34+
# OTEL_SUPERVISOR_PASSTHROUGH_LOGS: 'true'
35+
# Uncomment to enable JSON schema in ClickHouse
36+
# Be sure to also set BETA_CH_OTEL_JSON_SCHEMA_ENABLED to 'true' in ch-server
37+
# OTEL_AGENT_FEATURE_GATE_ARG: '--feature-gates=clickhouse.json'
3338
volumes:
3439
- ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml
3540
- ./docker/otel-collector/supervisor_docker.yaml:/etc/otel/supervisor.yaml
@@ -46,14 +51,17 @@ services:
4651
ch-server:
4752
condition: service_healthy
4853
ch-server:
49-
image: clickhouse/clickhouse-server:24-alpine
54+
image: clickhouse/clickhouse-server:25.6-alpine
5055
ports:
5156
- 8123:8123 # http api
5257
- 9000:9000 # native
5358
environment:
5459
# default settings
5560
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
5661
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE: ${HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE}
62+
# Set to 'true' to allow for proper OTel JSON Schema creation
63+
# Be sure to also set the OTEL_AGENT_FEATURE_GATE_ARG env in otel-collector
64+
# BETA_CH_OTEL_JSON_SCHEMA_ENABLED: 'true'
5765
volumes:
5866
- ./docker/clickhouse/local/config.xml:/etc/clickhouse-server/config.xml
5967
- ./docker/clickhouse/local/users.xml:/etc/clickhouse-server/users.xml

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ services:
7777
- ch-server
7878
- db
7979
ch-server:
80-
image: clickhouse/clickhouse-server:24-alpine
80+
image: clickhouse/clickhouse-server:25.6-alpine
8181
# WARNING: Exposing the database port will make it accessible from outside the container,
8282
# potentially allowing unauthorized access. If you uncomment the ports below,
8383
# ensure to secure your database (e.g., with strong authentication, proper network rules, and firewalls).

docker/clickhouse/local/config.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<logger>
44
<level>debug</level>
55
<console>true</console>
6-
<log remove="remove"/>
7-
<errorlog remove="remove"/>
6+
<log remove="remove" />
7+
<errorlog remove="remove" />
88
</logger>
99

1010
<listen_host>0.0.0.0</listen_host>
@@ -23,7 +23,12 @@
2323
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
2424
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
2525

26-
<users_config>users.xml</users_config>
26+
<user_directories>
27+
<users_xml>
28+
<path>users.xml</path>
29+
</users_xml>
30+
</user_directories>
31+
<!-- <users_config>users.xml</users_config> -->
2732
<default_profile>default</default_profile>
2833
<default_database>default</default_database>
2934
<timezone>UTC</timezone>
@@ -46,7 +51,8 @@
4651
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
4752
</query_log>
4853

49-
<!-- Metric log contains rows with current values of ProfileEvents, CurrentMetrics collected with "collect_interval_milliseconds" interval. -->
54+
<!-- Metric log contains rows with current values of ProfileEvents, CurrentMetrics collected
55+
with "collect_interval_milliseconds" interval. -->
5056
<metric_log>
5157
<database>system</database>
5258
<table>metric_log</table>
@@ -113,7 +119,8 @@
113119
</processors_profile_log>
114120

115121
<!-- Uncomment if use part log.
116-
Part log contains information about all actions with parts in MergeTree tables (creation, deletion, merges, downloads).-->
122+
Part log contains information about all actions with parts in MergeTree tables (creation, deletion,
123+
merges, downloads).-->
117124
<part_log>
118125
<database>system</database>
119126
<table>part_log</table>

docker/clickhouse/local/init-db.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash
22
set -e
33

4+
# We don't have a JSON schema yet, so let's let the collector create the tables
5+
if [ "$BETA_CH_OTEL_JSON_SCHEMA_ENABLED" = "true" ]; then
6+
exit 0
7+
fi
8+
49
DATABASE=${HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE:-default}
510

611
clickhouse client -n <<EOFSQL

docker/otel-collector/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## base #############################################################################################
2-
FROM otel/opentelemetry-collector-contrib:0.126.0 AS col
3-
FROM otel/opentelemetry-collector-opampsupervisor:0.126.0 AS supervisor
2+
FROM otel/opentelemetry-collector-contrib:0.129.1 AS col
3+
FROM otel/opentelemetry-collector-opampsupervisor:0.128.0 AS supervisor
44

55
# From: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/aa5c3aa4c7ec174361fcaf908de8eaca72263078/cmd/opampsupervisor/Dockerfile#L18
66
FROM alpine:latest@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c AS prep

docker/otel-collector/config.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ processors:
7878
SEVERITY_NUMBER_TRACE
7979
# Infer: else
8080
- set(log.severity_text, "info") where log.severity_number == 0
81-
- set(log.severity_number, SEVERITY_NUMBER_INFO) where log.severity_number == 0
81+
- set(log.severity_number, SEVERITY_NUMBER_INFO) where
82+
log.severity_number == 0
8283
- context: log
8384
error_mode: ignore
8485
statements:
@@ -142,7 +143,12 @@ extensions:
142143
service:
143144
telemetry:
144145
metrics:
145-
address: ':8888'
146+
readers:
147+
- pull:
148+
exporter:
149+
prometheus:
150+
host: '0.0.0.0'
151+
port: 8888
146152
logs:
147153
level: ${HYPERDX_LOG_LEVEL}
148154
extensions: [health_check]

docker/otel-collector/supervisor_docker.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ agent:
2020
executable: /otelcontribcol
2121
config_files:
2222
- /etc/otelcol-contrib/config.yaml
23+
args:
24+
- ${env:OTEL_AGENT_FEATURE_GATE_ARG}
2325
passthrough_logs: ${env:OTEL_SUPERVISOR_PASSTHROUGH_LOGS}
2426

2527
storage:

packages/app/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
},
99
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
1010
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
11-
transformIgnorePatterns: ['/node_modules/(?!(ky|ky-universal))'],
11+
transformIgnorePatterns: ['/node_modules/(?!(ky|ky-universal|flat))'],
1212
moduleNameMapper: {
1313
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
1414
'^@/(.*)$': '<rootDir>/src/$1',

0 commit comments

Comments
 (0)