---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  annotations:
    networkoperator.openshift.io/ignore-errors: ""
  creationTimestamp: "2022-03-08T10:38:10Z"
  generation: 1
  labels:
    prometheus: k8s
    role: alert-rules
  managedFields:
  - apiVersion: monitoring.coreos.com/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:networkoperator.openshift.io/ignore-errors: {}
        f:labels:
          .: {}
          f:prometheus: {}
          f:role: {}
        f:ownerReferences: {}
      f:spec:
        .: {}
        f:groups: {}
    manager: cluster-network-operator
    operation: Update
    time: "2022-03-08T10:38:10Z"
  name: networking-rules
  namespace: openshift-sdn
  ownerReferences:
  - apiVersion: operator.openshift.io/v1
    blockOwnerDeletion: true
    controller: true
    kind: Network
    name: cluster
    uid: b48e3238-e625-4cc0-acf5-5166b34864a9
  resourceVersion: "4957"
  selfLink: /apis/monitoring.coreos.com/v1/namespaces/openshift-sdn/prometheusrules/networking-rules
  uid: c70122fe-8baa-4d0b-883a-165d716b2fc9
spec:
  groups:
  - name: cluster-network-operator-sdn.rules
    rules:
    - alert: NodeWithoutOVSPod
      annotations:
        message: |
          All nodes should be running an ovs pod, {{ $labels.node }} is not.
      expr: |
        (kube_node_info unless on(node) topk by (node) (1, kube_pod_info{namespace="openshift-sdn",  pod=~"ovs.*"})) > 0
      for: 10m
      labels:
        severity: warning
    - alert: NodeWithoutSDNPod
      annotations:
        message: |
          All nodes should be running an sdn pod, {{ $labels.node }} is not.
      expr: |
        (kube_node_info unless on(node) topk by (node) (1, kube_pod_info{namespace="openshift-sdn",  pod=~"sdn.*"})) > 0
      for: 10m
      labels:
        severity: warning
    - alert: NodeProxyApplySlow
      annotations:
        message: SDN pod {{ $labels.pod }} on node {{ $labels.node }} is taking too long, on average, to apply kubernetes service rules to iptables.
      expr: "histogram_quantile(.95, kubeproxy_sync_proxy_rules_duration_seconds_bucket) \n* on(namespace, pod) group_right topk by (namespace, pod) (1, kube_pod_info{namespace=\"openshift-sdn\",  pod=~\"sdn-[^-]*\"}) > 15\n"
      labels:
        severity: warning
    - alert: ClusterProxyApplySlow
      annotations:
        message: The cluster is taking too long, on average, to apply kubernetes service rules to iptables.
      expr: |
        histogram_quantile(0.95, sum(rate(kubeproxy_sync_proxy_rules_duration_seconds_bucket[5m])) by (le)) > 10
      labels:
        severity: warning
    - alert: NodeProxyApplyStale
      annotations:
        message: SDN pod {{ $labels.pod }} on node {{ $labels.node }} has stale kubernetes service rules in iptables.
      expr: |
        (kubeproxy_sync_proxy_rules_last_queued_timestamp_seconds - kubeproxy_sync_proxy_rules_last_timestamp_seconds)
        * on(namespace, pod) group_right() topk by (namespace, pod) (1, kube_pod_info{namespace="openshift-sdn",pod=~"sdn-[^-]*"})
        > 30
      for: 5m
      labels:
        severity: warning
    - alert: SDNPodNotReady
      annotations:
        message: SDN pod {{ $labels.pod }} on node {{ $labels.node }} is not ready.
      expr: |
        kube_pod_status_ready{namespace='openshift-sdn', condition='true'} == 0
      for: 10m
      labels:
        severity: warning
