From 2f48a0bd73ef0816c2c86d0df96ab642b8bea960 Mon Sep 17 00:00:00 2001 From: MaverickD650 <92877124+MaverickD650@users.noreply.github.com> Date: Wed, 18 Jan 2023 07:42:25 +0000 Subject: [PATCH] fix (Uptime Kuma): Missing metrics port (#6435) * (fix) Uptime Kuma: Missing metrics port * bump * common annotations * add some tidbits * Update charts/stable/uptime-kuma/templates/_prometheusrules.tpl Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> * Update charts/stable/uptime-kuma/templates/_prometheusrules.tpl Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> * common * common 2 * Update charts/stable/uptime-kuma/templates/common.yaml Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/stable/uptime-kuma/Chart.yaml | 2 +- .../templates/_prometheusrules.tpl | 23 +++++++++++++++++++ ...ervicemonitor.yaml => _servicemonitor.tpl} | 3 +++ .../stable/uptime-kuma/templates/common.yaml | 16 ++++++++++++- charts/stable/uptime-kuma/values.yaml | 11 +++++++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 charts/stable/uptime-kuma/templates/_prometheusrules.tpl rename charts/stable/uptime-kuma/templates/{servicemonitor.yaml => _servicemonitor.tpl} (93%) diff --git a/charts/stable/uptime-kuma/Chart.yaml b/charts/stable/uptime-kuma/Chart.yaml index e5c6807d2fd..70ac5d14459 100644 --- a/charts/stable/uptime-kuma/Chart.yaml +++ b/charts/stable/uptime-kuma/Chart.yaml @@ -21,7 +21,7 @@ sources: - https://github.com/truecharts/charts/tree/master/charts/stable/uptime-kuma - https://github.com/louislam/uptime-kuma type: application -version: 5.0.11 +version: 5.0.12 annotations: truecharts.org/catagories: | - monitoring diff --git a/charts/stable/uptime-kuma/templates/_prometheusrules.tpl b/charts/stable/uptime-kuma/templates/_prometheusrules.tpl new file mode 100644 index 00000000000..a9092303d92 --- /dev/null +++ b/charts/stable/uptime-kuma/templates/_prometheusrules.tpl @@ -0,0 +1,23 @@ +{{- define "uptime.prometheusrule" -}} +{{- if hasKey .Values "metrics" }} +{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ include "tc.common.names.fullname" . }} + labels: + {{- include "tc.common.labels" . | nindent 4 }} + {{- with .Values.metrics.prometheusRule.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + groups: + - name: {{ include "tc.common.names.fullname" . }} + rules: + {{- with .Values.metrics.prometheusRule.rules }} + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} +{{- end }} +{{- end -}} diff --git a/charts/stable/uptime-kuma/templates/servicemonitor.yaml b/charts/stable/uptime-kuma/templates/_servicemonitor.tpl similarity index 93% rename from charts/stable/uptime-kuma/templates/servicemonitor.yaml rename to charts/stable/uptime-kuma/templates/_servicemonitor.tpl index 99036fc3da9..6e788d4c9c6 100644 --- a/charts/stable/uptime-kuma/templates/servicemonitor.yaml +++ b/charts/stable/uptime-kuma/templates/_servicemonitor.tpl @@ -1,5 +1,7 @@ +{{- define "uptime.servicemonitor" -}} {{- if hasKey .Values "metrics" }} {{- if .Values.metrics.enabled }} +--- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -24,3 +26,4 @@ spec: path: /metrics {{- end }} {{- end }} +{{- end -}} diff --git a/charts/stable/uptime-kuma/templates/common.yaml b/charts/stable/uptime-kuma/templates/common.yaml index c1a366e1cf0..9699ed7d301 100644 --- a/charts/stable/uptime-kuma/templates/common.yaml +++ b/charts/stable/uptime-kuma/templates/common.yaml @@ -1 +1,15 @@ -{{ include "tc.common.loader.all" . }} +{{- include "tc.common.loader.init" . }} + +{{- if hasKey .Values "metrics" -}} +{{- if .Values.metrics.enabled -}} +{{- $_ := set .Values.podAnnotations "prometheus.io/scrape" "true" -}} +{{- $_ := set .Values.podAnnotations "prometheus.io/path" "/metrics" -}} +{{- $_ := set .Values.podAnnotations "prometheus.io/port" (.Values.service.metrics.ports.metrics.targetPort | quote) -}} +{{- end -}} +{{- end -}} + +{{- include "uptime.servicemonitor" . -}} +{{- include "uptime.prometheusrule" . -}} + +{{/* Render the templates */}} +{{ include "tc.common.loader.apply" . }} diff --git a/charts/stable/uptime-kuma/values.yaml b/charts/stable/uptime-kuma/values.yaml index c213c8585e2..ab8cb561d44 100644 --- a/charts/stable/uptime-kuma/values.yaml +++ b/charts/stable/uptime-kuma/values.yaml @@ -20,6 +20,17 @@ service: port: 3001 targetPort: 3001 + # Metrics Services + metrics: + enabled: true + type: ClusterIP + ports: + metrics: + enabled: true + protocol: HTTP + port: 3002 + targetPort: 3002 + persistence: config: enabled: true