diff --git a/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml b/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml index 62e55425e..96b77825c 100644 --- a/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml +++ b/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml @@ -12,6 +12,7 @@ metadata: annotations: {{ include "altinity-clickhouse-operator.annotations" . | nindent 4 }} spec: endpoints: +{{- if .Values.metrics.enabled }} - port: ch-metrics # 8888 {{- with .Values.serviceMonitor.clickhouseMetrics.interval }} interval: {{ . }} @@ -27,6 +28,7 @@ spec: metricRelabelings: {{- toYaml . | nindent 8 }} {{- end }} +{{- end }} - port: op-metrics # 9999 {{- with .Values.serviceMonitor.operatorMetrics.interval }} interval: {{ . }} diff --git a/dev/generate_helm_chart.sh b/dev/generate_helm_chart.sh index a31ebc6b2..5a3ce88f9 100755 --- a/dev/generate_helm_chart.sh +++ b/dev/generate_helm_chart.sh @@ -178,6 +178,8 @@ function update_service_resource() { yq e -i '.metadata.annotations |= "{{ include \"altinity-clickhouse-operator.annotations\" . | nindent 4 }}"' "${file}" yq e -i '.spec.selector |= "{{ include \"altinity-clickhouse-operator.selectorLabels\" . | nindent 4 }}"' "${file}" + perl -pi -e 's/(\s+- port: 8888)/{{ if .Values.metrics.enabled }}\n$1/g' "${file}" + perl -pi -e 's/(name: ch-metrics)/$1\n{{ end }}/g' "${file}" perl -pi -e "s/'//g" "${file}" }