diff --git a/deploy/helm/clickhouse-operator/README.md b/deploy/helm/clickhouse-operator/README.md index 16be8860e..81ff8b67d 100644 --- a/deploy/helm/clickhouse-operator/README.md +++ b/deploy/helm/clickhouse-operator/README.md @@ -133,7 +133,14 @@ crdHook: | serviceMonitor.clickhouseMetrics.metricRelabelings | list | `[]` | | | serviceMonitor.clickhouseMetrics.relabelings | list | `[]` | | | serviceMonitor.clickhouseMetrics.scrapeTimeout | string | `""` | | -| serviceMonitor.enabled | bool | `false` | ServiceMonitor Custom resource is created for a [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator) In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999. Ypu can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below | +| serviceMonitor.enabled | bool | `false` | ServiceMonitor Custom resource is created for a [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator) In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999 and separate ServiceMonitor for keeper-metrics. You can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below | +| serviceMonitor.keeperMetrics.enabled | bool | `true` | create separate ServiceMonitor for scrape native ClickHouse Keeper prometheus endpoint from every keeper service managed by operator (matched by `clickhouse-keeper.altinity.com/app: chop` label). Keeper shall expose prometheus endpoint via `prometheus/*` settings in CHK manifest and named port in serviceTemplate | +| serviceMonitor.keeperMetrics.interval | string | `"30s"` | | +| serviceMonitor.keeperMetrics.metricRelabelings | list | `[]` | | +| serviceMonitor.keeperMetrics.namespaceSelector | object | `{"any":true}` | namespaces where prometheus-operator will discover keeper services, `any: true` means all namespaces | +| serviceMonitor.keeperMetrics.port | string | `"metrics"` | name of the port in keeper Service which expose native keeper prometheus endpoint | +| serviceMonitor.keeperMetrics.relabelings | list | `[]` | | +| serviceMonitor.keeperMetrics.scrapeTimeout | string | `""` | | | serviceMonitor.operatorMetrics.interval | string | `"30s"` | | | serviceMonitor.operatorMetrics.metricRelabelings | list | `[]` | | | serviceMonitor.operatorMetrics.relabelings | list | `[]` | | diff --git a/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml b/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml index 96b77825c..9bc5ac423 100644 --- a/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml +++ b/deploy/helm/clickhouse-operator/templates/servicemonitor.yaml @@ -47,4 +47,40 @@ spec: selector: matchLabels: {{- include "altinity-clickhouse-operator.selectorLabels" . | nindent 6 }} +{{- if .Values.serviceMonitor.keeperMetrics.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ printf "%s-keeper-metrics" (include "altinity-clickhouse-operator.fullname" .) }} + namespace: {{ include "altinity-clickhouse-operator.namespace" . }} + labels: + {{- include "altinity-clickhouse-operator.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.additionalLabels }} + {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} + annotations: {{ include "altinity-clickhouse-operator.annotations" . | nindent 4 }} +spec: + endpoints: + - port: {{ .Values.serviceMonitor.keeperMetrics.port }} # native keeper prometheus endpoint, requires prometheus/* settings in CHK and `metrics` port in serviceTemplate + {{- with .Values.serviceMonitor.keeperMetrics.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.serviceMonitor.keeperMetrics.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + {{- with .Values.serviceMonitor.keeperMetrics.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.serviceMonitor.keeperMetrics.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + namespaceSelector: + {{- toYaml .Values.serviceMonitor.keeperMetrics.namespaceSelector | nindent 4 }} + selector: + matchLabels: + clickhouse-keeper.altinity.com/app: chop +{{- end }} {{- end }} diff --git a/deploy/helm/clickhouse-operator/values.schema.json b/deploy/helm/clickhouse-operator/values.schema.json index f51eda897..1409aa77b 100644 --- a/deploy/helm/clickhouse-operator/values.schema.json +++ b/deploy/helm/clickhouse-operator/values.schema.json @@ -979,9 +979,38 @@ } }, "enabled": { - "description": "ServiceMonitor Custom resource is created for a [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator) In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999. Ypu can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below", + "description": "ServiceMonitor Custom resource is created for a [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator) In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999 and separate ServiceMonitor for keeper-metrics. You can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below", "type": "boolean" }, + "keeperMetrics": { + "type": "object", + "properties": { + "enabled": { + "description": "create separate ServiceMonitor for scrape native ClickHouse Keeper prometheus endpoint from every keeper service managed by operator (matched by `clickhouse-keeper.altinity.com/app: chop` label). Keeper shall expose prometheus endpoint via `prometheus/*` settings in CHK manifest and named port in serviceTemplate", + "type": "boolean" + }, + "interval": { + "type": "string" + }, + "metricRelabelings": { + "type": "array" + }, + "namespaceSelector": { + "description": "namespaces where prometheus-operator will discover keeper services, `any: true` means all namespaces", + "type": "object" + }, + "port": { + "description": "name of the port in keeper Service which expose native keeper prometheus endpoint", + "type": "string" + }, + "relabelings": { + "type": "array" + }, + "scrapeTimeout": { + "type": "string" + } + } + }, "operatorMetrics": { "type": "object", "properties": { diff --git a/deploy/helm/clickhouse-operator/values.yaml b/deploy/helm/clickhouse-operator/values.yaml index a0b60c024..8f8d5d9c9 100644 --- a/deploy/helm/clickhouse-operator/values.yaml +++ b/deploy/helm/clickhouse-operator/values.yaml @@ -200,7 +200,7 @@ podSecurityContext: {} topologySpreadConstraints: [] serviceMonitor: # serviceMonitor.enabled -- ServiceMonitor Custom resource is created for a [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator) - # In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999. Ypu can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below + # In serviceMonitor will be created two endpoints ch-metrics on port 8888 and op-metrics # 9999 and separate ServiceMonitor for keeper-metrics. You can specify interval, scrapeTimeout, relabelings, metricRelabelings for each endpoint below enabled: false # serviceMonitor.additionalLabels -- additional labels for service monitor additionalLabels: {} @@ -222,6 +222,22 @@ serviceMonitor: relabelings: [] # serviceMonitor.metricRelabelings for op-metrics endpoint -- Prometheus [MetricRelabelConfigs] to apply to samples before ingestio metricRelabelings: [] + keeperMetrics: + # serviceMonitor.keeperMetrics.enabled -- create separate ServiceMonitor for scrape native ClickHouse Keeper prometheus endpoint from every keeper service managed by operator (matched by `clickhouse-keeper.altinity.com/app: chop` label). Keeper shall expose prometheus endpoint via `prometheus/*` settings in CHK manifest and named port in serviceTemplate + enabled: true + # serviceMonitor.keeperMetrics.port -- name of the port in keeper Service which expose native keeper prometheus endpoint + port: metrics + # serviceMonitor.keeperMetrics.namespaceSelector -- namespaces where prometheus-operator will discover keeper services, `any: true` means all namespaces + namespaceSelector: + any: true + # serviceMonitor.interval for keeper-metrics endpoint -- + interval: 30s + # serviceMonitor.scrapeTimeout for keeper-metrics endpoint -- Prometheus ServiceMonitor scrapeTimeout. If empty, Prometheus uses the global scrape timeout unless it is less than the target's scrape interval value in which the latter is used. + scrapeTimeout: "" + # serviceMonitor.relabelings for keeper-metrics endpoint -- Prometheus [RelabelConfigs] to apply to samples before scraping + relabelings: [] + # serviceMonitor.metricRelabelings for keeper-metrics endpoint -- Prometheus [MetricRelabelConfigs] to apply to samples before ingestio + metricRelabelings: [] # configs -- clickhouse operator configs # @default -- check the `values.yaml` file for the config content (auto-generated from latest operator release) configs: