charts/k8up/templates/prometheus/prometheusrule.yaml

Summary

Maintainability
Test Coverage
{{- if and .Values.metrics.prometheusRule.enabled (or .Values.metrics.prometheusRule.createDefaultRules .Values.metrics.prometheusRule.additionalRules) -}}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ include "k8up.fullname" . }}-rule
  namespace: {{ default .Release.Namespace .Values.metrics.prometheusRule.namespace }}
  labels:
    {{- include "k8up.labels" . | nindent 4 }}
    {{- with .Values.metrics.prometheusRule.additionalLabels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  groups:
    - name: K8up
      rules:
        {{- if .Values.metrics.prometheusRule.createDefaultRules }}
        - alert: K8upResticErrors
          expr: k8up_backup_restic_last_errors > 0
          for: 1m
          labels:
            severity: critical
          annotations:
            summary: Amount of errors of last restic backup
            description: This alert is fired when error number is > 0
            runbook_url: https://k8up.io/k8up/explanations/runbooks/K8upResticErrors.html
        - alert: K8upBackupNotRunning
          expr: sum(rate(k8up_jobs_total[25h])) == 0 and on(namespace) k8up_schedules_gauge > 0
          for: 1m
          labels:
            severity: critical
          annotations:
            summary: "No K8up jobs were run in {{ "{{ $labels.namespace }}" }} within the last 24 hours. Check the operator, there might be a deadlock"
            runbook_url: https://k8up.io/k8up/explanations/runbooks/K8upBackupNotRunning.html
        {{- range .Values.metrics.prometheusRule.jobFailedRulesFor }}
        - alert: K8up{{- . | title -}}Failed
          expr: (sum(kube_job_status_failed) by(job_name, namespace) * on(job_name, namespace) group_right() kube_job_labels{label_k8up_syn_tools_type="{{- . -}}"}) > 0
          for: 1m
          labels:
            severity: critical
          annotations:
            summary: "Job in {{ "{{ $labels.namespace }}" }} of type {{ "{{ $labels.label_k8up_syn_tools_type }}" }} failed"
            runbook_url: https://k8up.io/k8up/explanations/runbooks/K8up{{- . | title -}}Failed.html
        {{- end }}
        {{- end }}
        {{- with .Values.metrics.prometheusRule.additionalRules }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
{{- end }}