---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  annotations:
    operator.cdi.kubevirt.io/lastAppliedConfiguration: '{"metadata":{"name":"prometheus-cdi-rules","namespace":"openshift-cnv","creationTimestamp":null,"labels":{"cdi.kubevirt.io":"","prometheus.cdi.kubevirt.io":"true"}},"spec":{"groups":[{"name":"recordingRules.rules","rules":[{"record":"kubevirt_cdi_clone_pods_high_restart","expr":"count(kube_pod_container_status_restarts_total{pod=~''.*-source-pod'',
      container=''cdi-clone-source''} \u003e 3) or on() vector(0)"},{"record":"kubevirt_cdi_import_pods_high_restart","expr":"count(kube_pod_container_status_restarts_total{pod=~''importer-.*'',
      container=''importer''} \u003e 3) or on() vector(0)"},{"record":"kubevirt_cdi_operator_up","expr":"sum(up{namespace=''openshift-cnv'',
      pod=~''cdi-operator-.*''} or vector(0))"},{"record":"kubevirt_cdi_upload_pods_high_restart","expr":"count(kube_pod_container_status_restarts_total{pod=~''cdi-upload-.*'',
      container=''cdi-upload-server''} \u003e 3) or on() vector(0)"}]},{"name":"alerts.rules","rules":[{"alert":"CDIDataImportCronOutdated","expr":"sum
      by(ns,cron_name) (kubevirt_cdi_dataimportcron_outdated{pending=\"false\"}) \u003e
      0","for":"15m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"warning","severity":"info"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDataImportCronOutdated.md","summary":"DataImportCron
      (recurring polling of VM templates disk image sources, also known as golden
      images) PVCs are not being updated on the defined schedule"}},{"alert":"CDIDataVolumeUnusualRestartCount","expr":"kubevirt_cdi_import_pods_high_restart
      \u003e 0 or kubevirt_cdi_upload_pods_high_restart \u003e 0 or kubevirt_cdi_clone_pods_high_restart
      \u003e 0","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"none","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDataVolumeUnusualRestartCount.md","summary":"Some
      CDI population workloads have an unusual restart count, meaning they are probably
      failing and need to be investigated"}},{"alert":"CDIDefaultStorageClassDegraded","expr":"sum(kubevirt_cdi_storageprofile_info{default=\"true\",degraded=\"false\"}
      or on() vector(0)) +\n\t\t\t\t\t\t\t\t sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\",degraded=\"false\"}
      or on() vector(0)) +\n\t\t\t\t\t\t\t\t on () (0*(sum(kubevirt_cdi_storageprofile_info{default=\"true\"})
      or sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\"}))) == 0","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"none","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDefaultStorageClassDegraded.md","summary":"Default
      storage class has no smart clone or ReadWriteMany"}},{"alert":"CDIMultipleDefaultVirtStorageClasses","expr":"sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\"}
      or on() vector(0)) \u003e 1","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"none","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIMultipleDefaultVirtStorageClasses.md","summary":"More
      than one default virtualization StorageClass detected"}},{"alert":"CDINoDefaultStorageClass","expr":"sum(kubevirt_cdi_storageprofile_info{default=\"true\"}
      or on() vector(0)) +\n\t\t\t\t\t\t\t\t sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\"}
      or on() vector(0)) +\n\t\t\t\t\t\t\t\t (count(kubevirt_cdi_datavolume_pending
      == 0) or on() vector(0)) == 0","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"none","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDINoDefaultStorageClass.md","summary":"No
      default StorageClass or virtualization StorageClass, and a DataVolume is pending
      for one"}},{"alert":"CDINotReady","expr":"kubevirt_cdi_cr_ready == 0","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"critical","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDINotReady.md","summary":"CDI
      is not available to use"}},{"alert":"CDIOperatorDown","expr":"kubevirt_cdi_operator_up
      == 0","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"critical","severity":"warning"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIOperatorDown.md","summary":"CDI
      operator is down"}},{"alert":"CDIStorageProfilesIncomplete","expr":"sum by(storageclass,provisioner)
      ((kubevirt_cdi_storageprofile_info{complete=\"false\"}\u003e0))","for":"5m","labels":{"kubernetes_operator_component":"containerized-data-importer","kubernetes_operator_part_of":"kubevirt","operator_health_impact":"none","severity":"info"},"annotations":{"runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIStorageProfilesIncomplete.md","summary":"Incomplete
      StorageProfile {{ $labels.storageclass }}, accessMode/volumeMode cannot be inferred
      by CDI for PVC population request"}}]}]}}'
  creationTimestamp: "2025-10-29T11:53:25Z"
  generation: 1
  labels:
    app.kubernetes.io/component: storage
    app.kubernetes.io/managed-by: cdi-operator
    app.kubernetes.io/part-of: hyperconverged-cluster
    app.kubernetes.io/version: 4.19.11
    cdi.kubevirt.io: ""
    prometheus.cdi.kubevirt.io: "true"
  managedFields:
  - apiVersion: monitoring.coreos.com/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:operator.cdi.kubevirt.io/lastAppliedConfiguration: {}
        f:labels:
          .: {}
          f:app.kubernetes.io/component: {}
          f:app.kubernetes.io/managed-by: {}
          f:app.kubernetes.io/part-of: {}
          f:app.kubernetes.io/version: {}
          f:cdi.kubevirt.io: {}
          f:prometheus.cdi.kubevirt.io: {}
        f:ownerReferences:
          .: {}
          k:{"uid":"d3932a57-9f4c-41fd-96eb-46836c1d62ca"}: {}
      f:spec:
        .: {}
        f:groups:
          .: {}
          k:{"name":"alerts.rules"}:
            .: {}
            f:name: {}
            f:rules: {}
          k:{"name":"recordingRules.rules"}:
            .: {}
            f:name: {}
            f:rules: {}
    manager: virt-cdi-operator
    operation: Update
    time: "2025-10-29T11:53:25Z"
  name: prometheus-cdi-rules
  namespace: openshift-cnv
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: Deployment
    name: cdi-deployment
    uid: d3932a57-9f4c-41fd-96eb-46836c1d62ca
  resourceVersion: "2144854"
  uid: a45d8e6f-b953-4c3f-b9c4-af420d9e7426
spec:
  groups:
  - name: recordingRules.rules
    rules:
    - expr: count(kube_pod_container_status_restarts_total{pod=~'.*-source-pod', container='cdi-clone-source'}
        > 3) or on() vector(0)
      record: kubevirt_cdi_clone_pods_high_restart
    - expr: count(kube_pod_container_status_restarts_total{pod=~'importer-.*', container='importer'}
        > 3) or on() vector(0)
      record: kubevirt_cdi_import_pods_high_restart
    - expr: sum(up{namespace='openshift-cnv', pod=~'cdi-operator-.*'} or vector(0))
      record: kubevirt_cdi_operator_up
    - expr: count(kube_pod_container_status_restarts_total{pod=~'cdi-upload-.*', container='cdi-upload-server'}
        > 3) or on() vector(0)
      record: kubevirt_cdi_upload_pods_high_restart
  - name: alerts.rules
    rules:
    - alert: CDIDataImportCronOutdated
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDataImportCronOutdated.md
        summary: DataImportCron (recurring polling of VM templates disk image sources,
          also known as golden images) PVCs are not being updated on the defined schedule
      expr: sum by(ns,cron_name) (kubevirt_cdi_dataimportcron_outdated{pending="false"})
        > 0
      for: 15m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: warning
        severity: info
    - alert: CDIDataVolumeUnusualRestartCount
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDataVolumeUnusualRestartCount.md
        summary: Some CDI population workloads have an unusual restart count, meaning
          they are probably failing and need to be investigated
      expr: kubevirt_cdi_import_pods_high_restart > 0 or kubevirt_cdi_upload_pods_high_restart
        > 0 or kubevirt_cdi_clone_pods_high_restart > 0
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: warning
    - alert: CDIDefaultStorageClassDegraded
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIDefaultStorageClassDegraded.md
        summary: Default storage class has no smart clone or ReadWriteMany
      expr: "sum(kubevirt_cdi_storageprofile_info{default=\"true\",degraded=\"false\"}
        or on() vector(0)) +\n\t\t\t\t\t\t\t\t sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\",degraded=\"false\"}
        or on() vector(0)) +\n\t\t\t\t\t\t\t\t on () (0*(sum(kubevirt_cdi_storageprofile_info{default=\"true\"})
        or sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\"}))) == 0"
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: warning
    - alert: CDIMultipleDefaultVirtStorageClasses
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIMultipleDefaultVirtStorageClasses.md
        summary: More than one default virtualization StorageClass detected
      expr: sum(kubevirt_cdi_storageprofile_info{virtdefault="true"} or on() vector(0))
        > 1
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: warning
    - alert: CDINoDefaultStorageClass
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDINoDefaultStorageClass.md
        summary: No default StorageClass or virtualization StorageClass, and a DataVolume
          is pending for one
      expr: "sum(kubevirt_cdi_storageprofile_info{default=\"true\"} or on() vector(0))
        +\n\t\t\t\t\t\t\t\t sum(kubevirt_cdi_storageprofile_info{virtdefault=\"true\"}
        or on() vector(0)) +\n\t\t\t\t\t\t\t\t (count(kubevirt_cdi_datavolume_pending
        == 0) or on() vector(0)) == 0"
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: warning
    - alert: CDINotReady
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDINotReady.md
        summary: CDI is not available to use
      expr: kubevirt_cdi_cr_ready == 0
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: warning
    - alert: CDIOperatorDown
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIOperatorDown.md
        summary: CDI operator is down
      expr: kubevirt_cdi_operator_up == 0
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: warning
    - alert: CDIStorageProfilesIncomplete
      annotations:
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/CDIStorageProfilesIncomplete.md
        summary: Incomplete StorageProfile {{ $labels.storageclass }}, accessMode/volumeMode
          cannot be inferred by CDI for PVC population request
      expr: sum by(storageclass,provisioner) ((kubevirt_cdi_storageprofile_info{complete="false"}>0))
      for: 5m
      labels:
        kubernetes_operator_component: containerized-data-importer
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: info
