From faecd0aa8d147d866024a990dde0617efae0f7ab Mon Sep 17 00:00:00 2001 From: Thomas Philipona Date: Sat, 14 Oct 2023 11:44:56 +0200 Subject: [PATCH] Add Prometheus Service Monitor --- .../_user-prometheus-servicemonitor.yaml | 20 +++++++++++++++++++ .../user-monitoring/templates/monitoring.yaml | 1 + 2 files changed, 21 insertions(+) create mode 100644 charts/user-monitoring/templates/_user-prometheus-servicemonitor.yaml diff --git a/charts/user-monitoring/templates/_user-prometheus-servicemonitor.yaml b/charts/user-monitoring/templates/_user-prometheus-servicemonitor.yaml new file mode 100644 index 0000000..18f68e0 --- /dev/null +++ b/charts/user-monitoring/templates/_user-prometheus-servicemonitor.yaml @@ -0,0 +1,20 @@ +{{- define "prometheus.servicemonitor" }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app.kubernetes.io/name: prometheus + user: {{ .Values.user }} + name: {{ .Values.user }}-prometheus-servicemonitor +spec: + endpoints: + - path: /metrics + port: web + namespaceSelector: + matchNames: + - {{ .Values.user }}-monitoring + selector: + matchLabels: + operated-prometheus: 'true' +{{- end }} \ No newline at end of file diff --git a/charts/user-monitoring/templates/monitoring.yaml b/charts/user-monitoring/templates/monitoring.yaml index 5e15750..20df5da 100644 --- a/charts/user-monitoring/templates/monitoring.yaml +++ b/charts/user-monitoring/templates/monitoring.yaml @@ -26,6 +26,7 @@ {{- if .Values.prometheus.enabled }} {{- template "prometheus.ingress" . }} {{- template "prometheus.prometheus" . }} + {{- template "prometheus.servicemonitor" . }} {{- template "prometheus.role" . }} {{- template "prometheus.rolebinding" . }} {{- template "prometheus.sa" . }}