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
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With