'How to configure alerts in Prometheus for diskspace
We have prometheus running on Win Server box, and WMI exporter on a separate box(client). Able to read client metrics in Prometheus. Now the requirement is the moment Diskspace =>90 % , send an email alert, so that we can run a job to clean up space using an automated job / manual job.
Could you please help on how to configure alert for diskspace >90
Solution 1:[1]
assuming you are using https://github.com/martinlindhe/wmi_exporter/blob/master/docs/collector.logical_disk.md you could use something along these lines for > 90 % use
- alert: DiskSpaceUsage
expr: 100.0 - 100 * (wmi_logical_disk_free_bytes / wmi_logical_disk_size_bytes) > 90
for: 10m
labels:
severity: high
annotations:
summary: "Disk Space Usage (instance {{ $labels.instance }})"
description: "Disk Space on Drive is used more than 90%\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
there are other examples on wmi_exporter repo for default node_exporter metrics ( not sure if available with windows ) it should be
- alert: DiskSpace10%Free
expr: 100 - (100 * node_filesystem_avail_bytes / node_filesystem_size_bytes) > 90
labels:
severity: moderate
annotations:
summary: "Instance {{ $labels.instance }} is low on disk space"
description: "diskspace on {{ $labels.instance }} is used over {{ $value }}% ."
ยดยดยด
Solution 2:[2]
You might want to alert based on if it's going to fill up, not based on how full it is:
- name: node.rules
rules:
- alert: DiskWillFillIn4Hours
expr: predict_linear(node_filesystem_free{job="node"}[1h], 4 * 3600) < 0
for: 5m
labels:
severity: page
https://www.robustperception.io/reduce-noise-from-disk-space-alerts
Solution 3:[3]
To send email notification based on alert you need to setup alertmanager with prometheus. Here is the guide how to do that: https://github.com/prometheus/alertmanager
Also you can configure the alert rules. I am using node exporter to fetch node metrics and using the following rule
- alert: DiskSpace10%Free
expr: node_exporter:node_filesystem_free:fs_used_percents >= 90
labels:
severity: moderate
annotations:
summary: "Instance {{ $labels.instance }} is low on disk space"
description: "{{ $labels.instance }} has only {{ $value }}% free."
You can configure the above rule according to WMI exporter and you will be good to go. Hope this helps.
Solution 4:[4]
groups:
- name: recording_rules
interval: 5s
rules:
- record: node_exporter:node_filesystem_free:fs_used_percents
expr: 100 - 100 * ( node_filesystem_free{mountpoint="/"} / node_filesystem_size{mountpoint="/"} )
- name: alerting_rules
rules:
- alert: DiskSpace10%Free
expr: node_exporter:node_filesystem_free:fs_used_percents >= 90
# Note that previous expression evaluates the metric defined in the recording rule.
labels:
severity: moderate
annotations:
summary: "Instance {{ $labels.instance }} is low on disk space"
description: "{{ $labels.instance }} has only {{ $value }}% free."
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Karsten |
Solution 2 | ptman |
Solution 3 | mhansen |
Solution 4 | Erik Rybka |