From d6723662d3bc82e933eb6497289b3501041caf88 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 22 May 2025 13:16:00 -0400 Subject: [PATCH 1/2] enhancement: Add ability to specify custom clickhouse domain for collector --- .../templates/otel-collector-deployment.yaml | 2 +- ...otel-collector-custom-clickhouse_test.yaml | 38 +++++++++++++++++++ charts/hdx-oss-v2/values.yaml | 2 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml diff --git a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml index 3523ea4..f4ad710 100644 --- a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml +++ b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml @@ -29,7 +29,7 @@ spec: - containerPort: {{ .Values.otel.healthPort }} env: - name: CLICKHOUSE_SERVER_ENDPOINT - value: "{{ include "hdx-oss.fullname" . }}-clickhouse:{{ .Values.clickhouse.nativePort }}" + value: "{{ .Values.otel.clickhouseEndpoint | default (printf "%s-clickhouse:%v" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}" - name: HYPERDX_LOG_LEVEL value: {{ .Values.hyperdx.logLevel }} - name: CLICKHOUSE_USER diff --git a/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml b/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml new file mode 100644 index 0000000..c37bb23 --- /dev/null +++ b/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml @@ -0,0 +1,38 @@ +suite: test OTEL collector with custom clickhouse endpoint +templates: + - otel-collector-deployment.yaml +tests: + - it: should use default Clickhouse endpoint when not specified + set: + otel: + enabled: true + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].env[0].name + value: CLICKHOUSE_SERVER_ENDPOINT + - documentIndex: 0 + matchRegex: + path: spec.template.spec.containers[0].env[0].value + pattern: ".*-clickhouse:[0-9]+" + + - it: should use custom Clickhouse endpoint when specified + set: + otel: + enabled: true + clickhouseEndpoint: "my-custom-clickhouse:9000" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].env[0].name + value: CLICKHOUSE_SERVER_ENDPOINT + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].env[0].value + value: "my-custom-clickhouse:9000" \ No newline at end of file diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index c7dbb0f..05f4815 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -60,6 +60,8 @@ otel: httpPort: 4318 healthPort: 8888 enabled: true + # Specify a custom Clickhouse endpoint if not using the built-in Clickhouse + # clickhouseEndpoint: "my-external-clickhouse:9000" persistence: mongodb: From ef0af40c43489e3776f91c4d713870e454f16ae8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 22 May 2025 13:48:35 -0400 Subject: [PATCH 2/2] Update env var name and add tests --- charts/hdx-oss-v2/templates/otel-collector-deployment.yaml | 4 ++-- .../__snapshot__/otel-collector-disabled_test.yaml.snap | 2 +- .../tests/otel-collector-custom-clickhouse_test.yaml | 6 +++--- charts/hdx-oss-v2/values.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml index f4ad710..fd14368 100644 --- a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml +++ b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml @@ -28,8 +28,8 @@ spec: - containerPort: {{ .Values.otel.httpPort }} - containerPort: {{ .Values.otel.healthPort }} env: - - name: CLICKHOUSE_SERVER_ENDPOINT - value: "{{ .Values.otel.clickhouseEndpoint | default (printf "%s-clickhouse:%v" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}" + - name: CLICKHOUSE_ENDPOINT + value: "{{ .Values.otel.clickhouseEndpoint | default (printf "tcp://%s-clickhouse:%v?dial_timeout=10s" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}" - name: HYPERDX_LOG_LEVEL value: {{ .Values.hyperdx.logLevel }} - name: CLICKHOUSE_USER diff --git a/charts/hdx-oss-v2/tests/__snapshot__/otel-collector-disabled_test.yaml.snap b/charts/hdx-oss-v2/tests/__snapshot__/otel-collector-disabled_test.yaml.snap index be43a61..db6d463 100644 --- a/charts/hdx-oss-v2/tests/__snapshot__/otel-collector-disabled_test.yaml.snap +++ b/charts/hdx-oss-v2/tests/__snapshot__/otel-collector-disabled_test.yaml.snap @@ -27,7 +27,7 @@ should render OTEL collector with custom ports: spec: containers: - env: - - name: CLICKHOUSE_SERVER_ENDPOINT + - name: CLICKHOUSE_ENDPOINT value: RELEASE-NAME-hdx-oss-v2-clickhouse:9000 - name: HYPERDX_LOG_LEVEL value: info diff --git a/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml b/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml index c37bb23..c022274 100644 --- a/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml +++ b/charts/hdx-oss-v2/tests/otel-collector-custom-clickhouse_test.yaml @@ -13,11 +13,11 @@ tests: - documentIndex: 0 equal: path: spec.template.spec.containers[0].env[0].name - value: CLICKHOUSE_SERVER_ENDPOINT + value: CLICKHOUSE_ENDPOINT - documentIndex: 0 matchRegex: path: spec.template.spec.containers[0].env[0].value - pattern: ".*-clickhouse:[0-9]+" + pattern: "tcp://.*-clickhouse:[0-9]+\\?dial_timeout=10s" - it: should use custom Clickhouse endpoint when specified set: @@ -31,7 +31,7 @@ tests: - documentIndex: 0 equal: path: spec.template.spec.containers[0].env[0].name - value: CLICKHOUSE_SERVER_ENDPOINT + value: CLICKHOUSE_ENDPOINT - documentIndex: 0 equal: path: spec.template.spec.containers[0].env[0].value diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index 05f4815..4187832 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -60,8 +60,8 @@ otel: httpPort: 4318 healthPort: 8888 enabled: true - # Specify a custom Clickhouse endpoint if not using the built-in Clickhouse - # clickhouseEndpoint: "my-external-clickhouse:9000" + # Clickhouse endpoint - defaults to built-in Clickhouse service + clickhouseEndpoint: "" persistence: mongodb: