openshift 4.6 prometheus rule with too many pod restart

11/25/2021

I'm a new bee with prometheus rule on openshift 4.6,

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: pmrule
  namespace: testing-rule
spec:
  groups:
    - name: podsrestart
      rules:
        - alert: PodsRestart
          expr: count(kube_pod_container_status_restarts_total) by (pod-name) > 5
          labels:
            severity: warning

And I will have this error,

$oc create -f test.yaml
The  "prometheusrules" is invalid: : 1:73: group "podsrestart", rule 1, "PodsRestart": could not parse expression: 1:56: parse error: unexpected <op:-> in grouping opts, expected "," or ")"

Do I need to configure first the group name somewhere before putting it in the alert? How about the name?

Thank you!

-- uniwinux
kubernetes
openshift
prometheus

0 Answers