apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: sonarr-4k-config-backup-source-local
  namespace: sonarr-4k
  labels:
    helm.sh/chart: volsync-target-config-2.0.0
    app.kubernetes.io/instance: sonarr-4k
    app.kubernetes.io/part-of: sonarr-4k
    app.kubernetes.io/version: "2.0.0"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: sonarr-4k-config-backup-source-local
spec:
  groups:
    - name: volsync.alerts
      rules:
        - alert: VolSyncBackupPodFailed
          expr: |
            (kube_pod_container_status_last_terminated_exitcode > 0)
            * on(pod, namespace) group_left(owner_name)
            kube_pod_owner{owner_kind="Job", owner_name=~"volsync-.*"}
          for: 1m
          labels:
            severity: critical
          annotations:
            summary: "VolSync Backup Pod failed in {{ $labels.namespace }}"
            description: |
              A pod for the VolSync backup of PVC 'sonarr-4k-config' failed with exit code {{ $value }}.
              Job: {{ $labels.owner_name }}
              Namespace: {{ $labels.namespace }}
