From ed3fb0e4493624514ebf36551d1c7baf9bb64ab6 Mon Sep 17 00:00:00 2001
From: Hai Nguyen <quanghai.ng1512@gmail.com>
Date: Thu, 25 Jan 2024 22:26:24 +0700
Subject: [PATCH 1/2] [KYUUBI #6006] Support additional labels for service
 monitor

---
 charts/kyuubi/templates/kyuubi-servicemonitor.yaml | 3 +++
 charts/kyuubi/values.yaml                          | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/charts/kyuubi/templates/kyuubi-servicemonitor.yaml b/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
index 11098a0eac2..bc3e0c3c120 100644
--- a/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
+++ b/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
@@ -22,6 +22,9 @@ metadata:
   name: {{ .Release.Name }}
   labels:
     {{- include "kyuubi.labels" . | nindent 4 }}
+    {{- if .Values.serviceMonitor.additionalLabels }}
+    {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
+    {{- end }}
 spec:
   selector:
     matchLabels:
diff --git a/charts/kyuubi/values.yaml b/charts/kyuubi/values.yaml
index 31d802fd4f4..287eafb5a2a 100644
--- a/charts/kyuubi/values.yaml
+++ b/charts/kyuubi/values.yaml
@@ -297,6 +297,8 @@ serviceMonitor:
   # The endpoints section in a ServiceMonitor specifies the metrics information for each target endpoint.
   # This allows you to collect metrics from multiple Services across your Kubernetes cluster in a standardized and automated way.
   endpoints: []
+  # Additional labels that can be used so ServiceMonitor will be discovered by Prometheus
+  additionalLabels: {}
 
 # Rules for the Prometheus Operator
 prometheusRule:

From 69a86c520cd495222922c775c200a2fb8496829f Mon Sep 17 00:00:00 2001
From: Hai Nguyen <quanghai.ng1512@gmail.com>
Date: Mon, 29 Jan 2024 11:50:00 +0700
Subject: [PATCH 2/2] chore: simplify labels values

---
 charts/kyuubi/templates/kyuubi-servicemonitor.yaml | 4 ++--
 charts/kyuubi/values.yaml                          | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/charts/kyuubi/templates/kyuubi-servicemonitor.yaml b/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
index bc3e0c3c120..937704bcc07 100644
--- a/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
+++ b/charts/kyuubi/templates/kyuubi-servicemonitor.yaml
@@ -22,8 +22,8 @@ metadata:
   name: {{ .Release.Name }}
   labels:
     {{- include "kyuubi.labels" . | nindent 4 }}
-    {{- if .Values.serviceMonitor.additionalLabels }}
-    {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
+    {{- if .Values.serviceMonitor.labels }}
+    {{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
     {{- end }}
 spec:
   selector:
diff --git a/charts/kyuubi/values.yaml b/charts/kyuubi/values.yaml
index 287eafb5a2a..b6b69621ec8 100644
--- a/charts/kyuubi/values.yaml
+++ b/charts/kyuubi/values.yaml
@@ -298,7 +298,7 @@ serviceMonitor:
   # This allows you to collect metrics from multiple Services across your Kubernetes cluster in a standardized and automated way.
   endpoints: []
   # Additional labels that can be used so ServiceMonitor will be discovered by Prometheus
-  additionalLabels: {}
+  labels: {}
 
 # Rules for the Prometheus Operator
 prometheusRule: