apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    prometheus: k8s
    role: alert-rules
  name: test
  namespace: openshift-machine-api
spec:
  groups:
    - name: machine-without-valid-node-ref
      rules:
        - alert: MachineWithoutValidNodeTest
          expr: |
             sum by (name, namespace) (mapi_machine_created_timestamp_seconds unless on(node) kube_node_info) > 0
          labels:
            severity: warning
          annotations:
            summary: machine does not have valid node reference
            description: |
              The {{ $labels.name }} machine does not have an associated node, which could be a sign of provisioning issues.  If the node was deleted from the API, you may delete the machine if appropriate.  For more information refer to 'oc -n openshift-machine-api get -o yaml machine {{ $labels.name }}'{{ with $console_url := "console_url" | query }}{{ if ne (len (label "url" (first $console_url ) ) ) 0}} or {{ label "url" (first $console_url ) }}/k8s/ns/openshift-machine-api/machine.openshift.io~v1beta1~Machine/{{ $labels.name }}{{ end }}{{ end }}.
