From 09c7dbe7e3d9b829d0ca955b9940d1c75f4d51b2 Mon Sep 17 00:00:00 2001 From: Kemp Po Date: Wed, 12 Jun 2024 02:31:23 +0800 Subject: [PATCH] Add ServiceMonitor --- charts/trino/README.md | 12 +++++++ charts/trino/templates/podmonitor.yaml | 22 +++++++++++++ charts/trino/templates/servicemonitor.yaml | 4 +-- charts/trino/values.yaml | 11 +++---- test-values.yaml | 38 ++++++++++++++++++++++ 5 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 charts/trino/templates/podmonitor.yaml diff --git a/charts/trino/README.md b/charts/trino/README.md index e47c340a..3aa1a42b 100644 --- a/charts/trino/README.md +++ b/charts/trino/README.md @@ -605,6 +605,18 @@ Fast distributed SQL query engine for big data analytics that helps you explore } } ``` +* `jmx.enabled` - bool, default: `false` +* `jmx.registryPort` - int, default: `9080` +* `jmx.serverPort` - int, default: `9081` +* `jmxExporter.enabled` - bool, default: `false` +* `jmxExporter.image` - string, default: `"bitnami/jmx-exporter:latest"` +* `jmxExporter.pullPolicy` - string, default: `"Always"` +* `jmxExporter.port` - int, default: `5556` +* `jmxExporter.configProperties` - list, default: `[]` +* `podMonitor.enabled` - bool, default: `false` +* `podMonitor.selector.prometheus` - string, default: `"kube-prometheus"` +* `podMonitor.path` - string, default: `"/admin/metrics"` +* `podMonitor.interval` - string, default: `"30s"` * `commonLabels` - object, default: `{}` Labels that get applied to every resource's metadata diff --git a/charts/trino/templates/podmonitor.yaml b/charts/trino/templates/podmonitor.yaml new file mode 100644 index 00000000..e50433b9 --- /dev/null +++ b/charts/trino/templates/podmonitor.yaml @@ -0,0 +1,22 @@ + +{{- if .Values.podMonitor.enabled -}} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ template "trino.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + release: prometheus-operator + {{- include "trino.labels" . | nindent 4 }} + {{- if .Values.podMonitor.selector }} + {{- toYaml .Values.podMonitor.selector | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "trino.selectorLabels" . | nindent 6 }} + endpoints: + - port: jmx-exporter + path: {{ .Values.serviceMonitor.path }} + interval: {{ .Values.serviceMonitor.interval }} +{{- end }} diff --git a/charts/trino/templates/servicemonitor.yaml b/charts/trino/templates/servicemonitor.yaml index 55c5e820..53536a28 100644 --- a/charts/trino/templates/servicemonitor.yaml +++ b/charts/trino/templates/servicemonitor.yaml @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - name: {{ template "trino.fullname" . }} + name: {{ include "trino.fullname" . }} labels: {{- include "trino.labels" . | nindent 4 }} {{- if .Values.serviceMonitor.selector }} @@ -15,7 +15,7 @@ spec: {{- include "trino.selectorLabels" . | nindent 6 }} app.kubernetes.io/component: coordinator endpoints: - - port: jmx-exporter + - port: jmx path: {{ .Values.serviceMonitor.path }} interval: {{ .Values.serviceMonitor.interval }} {{- end }} \ No newline at end of file diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index 960099c4..4b3d3f60 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -763,16 +763,15 @@ jmx: # help: 'ThreadCount (java.lang<>ThreadCount)' # type: UNTYPED -podMonitor: - # - podMonitor is a resource from prometheus-operator: - # https://github.com/prometheus-operator/prometheus-operator +serviceMonitor: + # serviceMonitor.enabled -- Set to true to create resources for the [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator). enabled: false - # labels for podMonitor, so that Prometheus can select it + # serviceMonitor.selector -- Labels for serviceMonitor, so that Prometheus can select it selector: prometheus: kube-prometheus - # the podMonitor web endpoint path + # serviceMonitor.path -- The serviceMonitor web endpoint path path: /admin/metrics - # the podMonitor web endpoint interval + # serviceMonitor.interval -- The serviceMonitor web endpoint interval interval: "30s" # -- Labels that get applied to every resource's metadata diff --git a/test-values.yaml b/test-values.yaml index 32902faa..f10d4c77 100644 --- a/test-values.yaml +++ b/test-values.yaml @@ -140,6 +140,44 @@ accessControl: ] } +jmx: + enabled: true + registryPort: 9080 + serverPort: 9081 + +jmxExporter: + enabled: true + image: bitnami/jmx-exporter:latest + pullPolicy: Always + port: 5556 + configProperties: | + startDelaySeconds: 0 + hostPort: 127.0.0.1:9080 + ssl: false + lowercaseOutputName: false + lowercaseOutputLabelNames: false + includeObjectNames: ["java.lang:type=Threading"] + autoExcludeObjectNameAttributes: true + excludeObjectNameAttributes: + "java.lang:type=OperatingSystem": + - "ObjectName" + "java.lang:type=Runtime": + - "ClassPath" + - "SystemProperties" + rules: + - pattern: 'java\.lang<(.*)>ThreadCount: (.*)' + name: java_lang_Threading_ThreadCount + value: '$2' + help: 'ThreadCount (java.lang<>ThreadCount)' + type: UNTYPED + +podMonitor: + enabled: true + selector: + prometheus: kube-prometheus + path: /admin/metrics + interval: "30s" + ingress: enabled: true hosts: