---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  creationTimestamp: "2025-10-29T11:52:47Z"
  generation: 1
  labels:
    app: kubevirt-hyperconverged
    app.kubernetes.io/component: monitoring
    app.kubernetes.io/managed-by: hco-operator
    app.kubernetes.io/part-of: hyperconverged-cluster
    app.kubernetes.io/version: 4.19.11
  managedFields:
  - apiVersion: monitoring.coreos.com/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:labels:
          .: {}
          f:app: {}
          f:app.kubernetes.io/component: {}
          f:app.kubernetes.io/managed-by: {}
          f:app.kubernetes.io/part-of: {}
          f:app.kubernetes.io/version: {}
        f:ownerReferences:
          .: {}
          k:{"uid":"dbceb915-8326-4fe5-abfa-39d66ac9f16e"}: {}
      f:spec:
        .: {}
        f:groups:
          .: {}
          k:{"name":"alerts.rules"}:
            .: {}
            f:name: {}
            f:rules: {}
          k:{"name":"recordingRules.rules"}:
            .: {}
            f:name: {}
            f:rules: {}
    manager: hyperconverged-cluster-operator
    operation: Update
    time: "2025-10-29T11:52:47Z"
  name: kubevirt-hyperconverged-prometheus-rule
  namespace: openshift-cnv
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: false
    controller: false
    kind: Deployment
    name: hco-operator
    uid: dbceb915-8326-4fe5-abfa-39d66ac9f16e
  resourceVersion: "2143333"
  uid: 8b3b55ac-188e-4c24-8c1e-2581e11531e2
spec:
  groups:
  - name: recordingRules.rules
    rules:
    - expr: sum(kube_pod_container_resource_requests{resource="cpu"} and on (pod)
        kube_pod_status_phase{phase="Running"} * on (pod) group_left kube_pod_labels{
        label_kubevirt_io="virt-launcher"} > 0)
      record: cluster:vmi_request_cpu_cores:sum
    - expr: sum by (container, reason)(kubevirt_memory_delta_from_requested_bytes)
      record: cnv_abnormal
    - expr: label_replace((vector(2) and on() ((kubevirt_hco_system_health_status==2)
        or (count(ALERTS{kubernetes_operator_part_of="kubevirt", alertstate="firing",
        operator_health_impact="critical"})>0))) or (vector(1) and on() ((kubevirt_hco_system_health_status==1)
        or (count(ALERTS{kubernetes_operator_part_of="kubevirt", alertstate="firing",
        operator_health_impact="warning"})>0))) or vector(0),"name","kubevirt-hyperconverged","","")
      record: kubevirt_hyperconverged_operator_health_status
  - name: alerts.rules
    rules:
    - alert: HCOInstallationIncomplete
      annotations:
        description: the installation was not completed; the HyperConverged custom
          resource is missing. In order to complete the installation of the Hyperconverged
          Cluster Operator you should create the HyperConverged custom resource.
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/HCOInstallationIncomplete.md
        summary: the installation was not completed; to complete the installation,
          create a HyperConverged custom resource.
      expr: kubevirt_hco_hyperconverged_cr_exists == 0
      for: 1h
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: info
    - alert: HCOMisconfiguredDescheduler
      annotations:
        description: Kube Descheduler is not correctly configured for KubeVirt
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/HCOMisconfiguredDescheduler.md
        summary: Kube Descheduler is not correctly configured for KubeVirt
      expr: kubevirt_hco_misconfigured_descheduler == 1
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: critical
    - alert: HCOOperatorConditionsUnhealthy
      annotations:
        description: HCO and its secondary resources are in a warning state due to
          system warning.
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/HCOOperatorConditionsUnhealthy.md
        summary: HCO and its secondary resources are in a warning state.
      expr: kubevirt_hco_system_health_status == 1.000000
      for: 10m
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: warning
        severity: warning
    - alert: HCOOperatorConditionsUnhealthy
      annotations:
        description: HCO and its secondary resources are in a critical state due to
          system error.
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/HCOOperatorConditionsUnhealthy.md
        summary: HCO and its secondary resources are in a critical state.
      expr: kubevirt_hco_system_health_status == 2.000000
      for: 10m
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: critical
    - alert: KubeVirtCRModified
      annotations:
        description: Out-of-band modification for {{ $labels.component_name }}.
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/KubeVirtCRModified.md
        summary: '{{ $value }} out-of-band CR modifications were detected in the last
          10 minutes.'
      expr: sum by(component_name) ((round(increase(kubevirt_hco_out_of_band_modifications_total[10m]))>0
        and kubevirt_hco_out_of_band_modifications_total offset 10m) or (kubevirt_hco_out_of_band_modifications_total
        != 0 unless kubevirt_hco_out_of_band_modifications_total offset 10m))
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: warning
        severity: warning
    - alert: SingleStackIPv6Unsupported
      annotations:
        description: KubeVirt Hyperconverged is not supported on a single stack IPv6
          cluster
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/SingleStackIPv6Unsupported.md
        summary: KubeVirt Hyperconverged is not supported on a single stack IPv6 cluster
      expr: kubevirt_hco_single_stack_ipv6 == 1
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: critical
        severity: critical
    - alert: UnsupportedHCOModification
      annotations:
        description: unsafe modification for the {{ $labels.annotation_name }} annotation
          in the HyperConverged resource.
        runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/openshift-virtualization-operator/UnsupportedHCOModification.md
        summary: '{{ $value }} unsafe modifications were detected in the HyperConverged
          resource.'
      expr: sum by(annotation_name, namespace) ((kubevirt_hco_unsafe_modifications)>0)
      labels:
        kubernetes_operator_component: hyperconverged-cluster-operator
        kubernetes_operator_part_of: kubevirt
        operator_health_impact: none
        severity: info
