From ff7cbd02951904abd40ae9587e011edea86d7f08 Mon Sep 17 00:00:00 2001 From: Frank Blechschmidt Date: Sun, 18 Jul 2021 19:13:07 -0700 Subject: [PATCH] Add support for Prometheus metrics in the Spark Driver (#5) --- charts/bullet/Chart.yaml | 2 +- .../templates/spark-backend-deployment.yaml | 2 + .../templates/spark-backend-podmonitor.yaml | 48 +++++++++++++++++++ charts/bullet/values.yaml | 9 ++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 charts/bullet/templates/spark-backend-podmonitor.yaml diff --git a/charts/bullet/Chart.yaml b/charts/bullet/Chart.yaml index fd96e50..acbde49 100644 --- a/charts/bullet/Chart.yaml +++ b/charts/bullet/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: bullet description: A real-time query engine for very large data streams type: application -version: 0.2.0 +version: 0.3.0 appVersion: "1.0.4" home: https://github.com/SketchBench/bullet-k8s # icon: diff --git a/charts/bullet/templates/spark-backend-deployment.yaml b/charts/bullet/templates/spark-backend-deployment.yaml index 7ec7ea3..4350f25 100644 --- a/charts/bullet/templates/spark-backend-deployment.yaml +++ b/charts/bullet/templates/spark-backend-deployment.yaml @@ -55,6 +55,8 @@ spec: - {{ printf "spark.executor.cores=%g" .Values.sparkBackend.executorCores }} - --conf - {{ printf "spark.executor.memory=%s" .Values.sparkBackend.executorMemory }} + - --conf + - {{ printf "spark.ui.prometheus.enabled=%t" .Values.sparkBackend.metrics.enabled }} - --class - com.yahoo.bullet.spark.BulletSparkStreamingMain - --jars diff --git a/charts/bullet/templates/spark-backend-podmonitor.yaml b/charts/bullet/templates/spark-backend-podmonitor.yaml new file mode 100644 index 0000000..b082cfb --- /dev/null +++ b/charts/bullet/templates/spark-backend-podmonitor.yaml @@ -0,0 +1,48 @@ +{{- if and .Values.sparkBackend.metrics.enabled .Values.sparkBackend.metrics.podMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "common.names.fullname" . }}-spark-backend + {{- if .Values.sparkBackend.metrics.podMonitor.namespace }} + namespace: {{ .Values.sparkBackend.metrics.podMonitor.namespace }} + {{- else }} + namespace: {{ .Release.Namespace }} + {{- end }} + labels: + {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: metrics + {{- if .Values.sparkBackend.metrics.podMonitor.additionalLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.sparkBackend.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + podMetricsEndpoints: + - port: "4040" + path: /metrics/executors/prometheus/ + {{- if .Values.sparkBackend.metrics.podMonitor.interval }} + interval: {{ .Values.sparkBackend.metrics.podMonitor.interval }} + {{- end }} + {{- if .Values.sparkBackend.metrics.podMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.sparkBackend.metrics.podMonitor.scrapeTimeout }} + {{- end }} + {{- range .Values.sparkBackend.metrics.podMonitor.extraMetricsEndpoints }} + - port: {{ .port }} + path: {{ .path }} + {{- if $.Values.sparkBackend.metrics.podMonitor.interval }} + interval: {{ $.Values.sparkBackend.metrics.podMonitor.interval }} + {{- end }} + {{- if $.Values.sparkBackend.metrics.podMonitor.scrapeTimeout }} + scrapeTimeout: {{ $.Values.sparkBackend.metrics.podMonitor.scrapeTimeout }} + {{- end }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/bullet/values.yaml b/charts/bullet/values.yaml index 6baed5d..9329056 100644 --- a/charts/bullet/values.yaml +++ b/charts/bullet/values.yaml @@ -69,6 +69,15 @@ sparkBackend: schemaDir: /bullet/schemas executorCores: 2 executorMemory: 3G + metrics: + enabled: false + podMonitor: + enabled: false + extraMetricsEndpoints: [] + namespace: "" + interval: 30s + scrapeTimeout: + additionalLabels: {} config: # See https://github.com/bullet-db/bullet-spark/blob/master/src/main/resources/bullet_spark_defaults.yaml ### Bullet ###