Skip to content

feat(metrics): add prometheus rules (and update exporter) #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/nextcloud/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: nextcloud
version: 6.6.10
version: 6.7.0
# renovate: image=docker.io/library/nextcloud
appVersion: 30.0.10
description: A file sharing server that puts the control and security of your own data back into your hands.
Expand Down
2 changes: 2 additions & 0 deletions charts/nextcloud/templates/metrics/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ spec:
value: {{ .Values.metrics.tlsSkipVerify | quote }}
- name: NEXTCLOUD_INFO_APPS
value: {{ .Values.metrics.info.apps | quote }}
- name: NEXTCLOUD_INFO_UPDATE
value: {{ .Values.metrics.info.update | quote }}
ports:
- name: metrics
containerPort: 9205
Expand Down
61 changes: 61 additions & 0 deletions charts/nextcloud/templates/metrics/prometheus-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.metrics.rules.enabled }}
{{- $fullname := include "nextcloud.fullname" . }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ $fullname }}
labels:
{{- include "nextcloud.labels" ( dict "rootContext" $ ) | nindent 4 }}
{{- with .Values.metrics.rules.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
groups:
{{- with .Values.metrics.rules.defaults }}
{{- if .enabled }}
{{- $filter := .filter | default (printf `namespace="%s",job="%s"` $.Release.Namespace $fullname) }}
- name: {{ $fullname }}-Defaults
rules:
- alert: "nextcloud: not reachable"
expr: 'avg(nextcloud_up{ {{ $filter }} }) without(endpoint,container,pod,instance) < 1'
for: 5m
labels:
severity: "critical"
{{- with .labels }}
{{- toYaml . | nindent 12 }}
{{- end }}
annotations:
{{`
summary: "Nextcloud in {{ $labels.namespace }} is not reachable by exporter"
`}}
- alert: "nextcloud: outdated version"
expr: 'sum(nextcloud_system_update_available{ {{ $filter }} }) without(endpoint,container,pod,instance) > 0'
labels:
severity: "warning"
{{- with .labels }}
{{- toYaml . | nindent 12 }}
{{- end }}
annotations:
{{`
summary: "Nextcloud in {{ $labels.namespace }} is outdated"
`}}
- alert: "nextcloud: outdated apps"
expr: 'sum(nextcloud_apps_updates_available_total{ {{ $filter }} }) without(endpoint,container,pod,instance) > 0'
labels:
severity: "warning"
{{- with .labels }}
{{- toYaml . | nindent 12 }}
{{- end }}
annotations:
{{`
summary: "Nextcloud in {{ $labels.namespace }} has {{ $value }} outdated Apps"
`}}
{{- end }}
{{- end }}{{/* end-with prometheus.rules.default */}}
{{- with .Values.metrics.rules.additionalRules }}
- name: {{ $fullname }}-Additional
rules:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

24 changes: 23 additions & 1 deletion charts/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,11 @@ metrics:
# Optional: becomes NEXTCLOUD_INFO_APPS env var in the nextcloud-exporter container.
# Enables gathering of apps-related metrics. Defaults to false
apps: false
update: false

image:
repository: xperimental/nextcloud-exporter
tag: 0.6.2
tag: 0.8.0
pullPolicy: IfNotPresent
# pullSecrets:
# - myRegistrKeySecretName
Expand Down Expand Up @@ -863,6 +864,27 @@ metrics:
##
labels: {}

rules:
# -- Deploy Prometheus Rules (Alerts) for the exporter
# @section -- Metrics
enabled: false
# -- Label on Prometheus Rules CRD Manifest
# @section -- Metrics
labels: {}
defaults:
# -- Add Default Rules
# @section -- Metrics
enabled: true
# -- Label on the rules (the severity is already set)
# @section -- Metrics
labels: {}
# -- Filter on metrics on alerts (default just for this helm-chart)
# @section -- Metrics
filter: ""
# -- Add own Rules to Prometheus Rules
# @section -- Metrics
additionalRules: []


rbac:
enabled: false
Expand Down