Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set prometheus rules in stable/prometheus chart values.yaml?

Using official Prometheus chart stable/prometheus.

Customized its values.yaml file to set alertmanager.yml file and serverFiles area.

At rules: {}:

https://github.com/kubernetes/charts/blob/master/stable/prometheus/values.yaml#L598

It's {}. How to write real alert rules as official format here?

For example, I tried:

  serverFiles:
    alerts: {}
    rules:
    # Alert for any instance that is unreachable for >5 minutes.
    - alert: InstanceDown
      expr: up == 0
      for: 5m
      labels:
        severity: page
      annotations:
        summary: "Instance {{ $labels.instance }} down"
      description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."

And ran $ helm install my_prometheus. Then pod got this error:

PersistentVolumeClaim is not bound: "sweet-terrier-prometheus-server"
Back-off restarting failed container
Error syncing pod
like image 464
online Avatar asked Dec 24 '22 10:12

online


1 Answers

serverFiles:
  alerts:
    groups:
    - name: NodeAlerts
      rules:
      - alert: NodeCPUUsage
        expr: (100 - (avg(irate(node_cpu{mode="idle"}[5m])) BY (instance) * 100)) > 75
        for: 2m
        labels:
          severity: alert
        annotations:
          description: '{{$labels.instance}}: CPU usage is above 75% (current value is:
            {{ $value }})'
          summary: '{{$labels.instance}}: High CPU usage detect

rules are for record rules, alert is for alert rules.

https://prometheus.io/docs/practices/rules/

like image 156
online Avatar answered Dec 27 '22 05:12

online