From 472ddf7a88502cd8fc32c236f8d84eb15d4afa03 Mon Sep 17 00:00:00 2001 From: Peixian Wang Date: Sun, 13 Apr 2025 19:13:43 -0400 Subject: [PATCH] Add prometheus integration with ServiceMonitor CRD --- charts/whatsapp-proxy-chart/Chart.yaml | 2 +- .../templates/servicemonitor.yaml | 24 +++++++++++++++++++ charts/whatsapp-proxy-chart/values.yaml | 5 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 charts/whatsapp-proxy-chart/templates/servicemonitor.yaml diff --git a/charts/whatsapp-proxy-chart/Chart.yaml b/charts/whatsapp-proxy-chart/Chart.yaml index 3dff6131..61930088 100644 --- a/charts/whatsapp-proxy-chart/Chart.yaml +++ b/charts/whatsapp-proxy-chart/Chart.yaml @@ -17,7 +17,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.2.0 +version: 1.2.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/whatsapp-proxy-chart/templates/servicemonitor.yaml b/charts/whatsapp-proxy-chart/templates/servicemonitor.yaml new file mode 100644 index 00000000..8a85f1fb --- /dev/null +++ b/charts/whatsapp-proxy-chart/templates/servicemonitor.yaml @@ -0,0 +1,24 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# License found in the LICENSE file in the root directory +# of this source tree. +{{- if .Values.enableServiceMonitor }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "whatsapp-proxy-chart.fullname" . }}-servicemonitor + namespace: default + labels: + release: {{ .Values.prometheus.release }} +spec: + endpoints: + - interval: 30s + path: /metrics + port: stats + namespaceSelector: + matchNames: + - default + selector: + matchLabels: + {{- include "whatsapp-proxy-chart.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/whatsapp-proxy-chart/values.yaml b/charts/whatsapp-proxy-chart/values.yaml index 52bab0c0..1045794d 100644 --- a/charts/whatsapp-proxy-chart/values.yaml +++ b/charts/whatsapp-proxy-chart/values.yaml @@ -102,3 +102,8 @@ nodeSelector: {} tolerations: [] affinity: {} + +# Enables service monitor for the prometheus operator. +enableServiceMonitor: false +prometheus: + release: my-prometheus-release