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