Skip to content

Commit

Permalink
Add JMX
Browse files Browse the repository at this point in the history
  • Loading branch information
kempspo committed Jun 11, 2024
1 parent d5104a7 commit b5b54b4
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 0 deletions.
7 changes: 7 additions & 0 deletions charts/trino/templates/configmap-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ data:
{{- range $configValue := .Values.coordinator.additionalJVMConfig }}
{{ $configValue }}
{{- end }}
{{- if .Values.jmx.enabled }}
-Dcom.sun.management.jmxremote.rmi.port={{ .Values.jmx.serverPort }}
{{- end }}

config.properties: |
coordinator=true
Expand All @@ -69,6 +72,10 @@ data:
http-server.https.port={{ .Values.server.config.https.port }}
http-server.https.keystore.path={{ .Values.server.config.https.keystore.path }}
{{- end }}
{{- if .Values.jmx.enabled }}
jmx.rmiregistry.port={{ .Values.jmx.registryPort }}
jmx.rmiserver.port={{ .Values.jmx.serverPort }}
{{- end }}
{{- if .Values.server.coordinatorExtraConfig }}
{{- .Values.server.coordinatorExtraConfig | nindent 4 }}
{{- end }}
Expand Down
13 changes: 13 additions & 0 deletions charts/trino/templates/configmap-jmx-exporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.jmx.exporter.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "trino.fullname" . }}-jmx-exporter-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: jmx
data:
jmx-exporter-config.yaml: |-
{{- .Values.jmx.exporter.configProperties | nindent 4 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/trino/templates/configmap-jmx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.jmx.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "trino.fullname" }}-jmx-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: jmx
data:
jmx-config: |
{{- range $configValue := .Values.jmx.configProperties }}
{{- $configValue }}
{{- end }}
# jmx-config.yaml: |
# startDelaySeconds: 0
# hostPort: 127.0.0.1:9080
# rules:
# - pattern: 'java.lang<type=Memory>(\w+): (.*)'
# name: jmx_jvm_memory_HeapMemoryUsed_$1
# help: "JVM heap memory $1"
# value: $2
# type: GAUGE
# - pattern: 'trino.memory*'
# - pattern: 'trino.execution<name=QueryManager>*'
# - pattern: 'iceberg*'
{{- end }}
29 changes: 29 additions & 0 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ spec:
path: group.db
{{- end }}
{{- end }}
{{- if .Values.jmx.exporter.enabled }}
- name: jmx-exporter-config-volume
configMap:
name: {{ template "trino.fullname" . }}-jmx-exporter-config
{{- end }}
{{- range .Values.configMounts }}
- name: {{ .name }}
configMap:
Expand Down Expand Up @@ -155,6 +160,19 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.jmx.enabled }}
- name: jmx-registry
containerPort: {{ .Values.jmx.registryPort }}
protocol: TCP
- name: jmx-server
containerPort: {{ .Values.jmx.serverPort }}
protocol: TCP
{{- end }}
{{- if .Values.podMonitor.enabled }}
- name: jmx-exporter
containerPort: {{ .Values.jmx.exporter.port }}
protocol: TCP
{{- end }}
{{- range $key, $value := .Values.coordinator.additionalExposedPorts }}
- name: {{ $value.name }}
containerPort: {{ $value.port }}
Expand All @@ -181,6 +199,17 @@ spec:
{{- toYaml .Values.coordinator.lifecycle | nindent 12 }}
resources:
{{- toYaml .Values.coordinator.resources | nindent 12 }}
{{- if .Values.jmx.exporter.enabled }}
- name: jmx-exporter
image: {{ .Values.jmx.exporter.image }}
imagePullPolicy: {{ .Values.jmx.exporter.pullPolicy }}
args:
- "{{ .Values.jmx.exporter.port }}"
- /etc/jmx-exporter/jmx-exporter-config.yaml
volumeMounts:
- mountPath: /etc/jmx-exporter/
name: jmx-exporter-config-volume
{{- end }}
{{- if .Values.sidecarContainers.coordinator }}
{{- toYaml .Values.sidecarContainers.coordinator | nindent 8 }}
{{- end }}
Expand Down
6 changes: 6 additions & 0 deletions charts/trino/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if .Values.jmx.exporter.enabled }}
- port: {{ .Values.jmx.exporter.port }}
targetPort: jmx-exporter
protocol: TCP
name: jmx-exporter
{{- end }}
{{- range $key, $value := .Values.coordinator.additionalExposedPorts }}
- port: {{ $value.servicePort }}
name: {{ $value.name }}
Expand Down
21 changes: 21 additions & 0 deletions charts/trino/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "trino.fullname" . }}
labels:
{{- include "trino.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.selector }}
{{- toYaml .Values.serviceMonitor.selector | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "trino.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: coordinator
endpoints:
- port: jmx-exporter
path: {{ .Values.serviceMonitor.path }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
48 changes: 48 additions & 0 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,54 @@ kafka:
# }
# ```

jmx:
# -- Set to true to enable the RMI server to expose Trino's [JMX metrics](https://trino.io/docs/current/admin/jmx.html).
enabled: false
registryPort: 9080
serverPort: 9081
exporter:
# jmx.exporter.enabled -- Set to true to export JMX Metrics via HTTP for [Prometheus](https://github.com/prometheus/jmx_exporter) consumption
enabled: false
image: bitnami/jmx-exporter:latest
pullPolicy: Always
port: 5556
configProperties: []
# jmx.exporter.configProperties -- JMX Config Properties is mounted to /etc/jmx-exporter/jmx-exporter-config.yaml
# @raw
# Example:
# ```yaml
# configProperties: |-
# startDelaySeconds: 0
# 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<type=Threading><(.*)>ThreadCount: (.*)'
# name: java_lang_Threading_ThreadCount
# value: '$2'
# help: 'ThreadCount (java.lang<type=Threading><>ThreadCount)'
# type: UNTYPED

podMonitor:
# - podMonitor is a resource from prometheus-operator:
# https://github.com/prometheus-operator/prometheus-operator
enabled: false
# labels for podMonitor, so that Prometheus can select it
selector:
prometheus: kube-prometheus
# the podMonitor web endpoint path
path: /admin/metrics
# the podMonitor web endpoint interval
interval: "30s"

# -- Labels that get applied to every resource's metadata
commonLabels: {}

Expand Down

0 comments on commit b5b54b4

Please sign in to comment.