# Disk, memory and CPU alerts that matter (Prometheus rules)

> The alerts worth having on a server are disk predicted to fill, low filesystem space, low available memory, OOM kills, sustained CPU and load, heavy swap and a node that stopped reporting, each with thresholds you tune.

URL: https://levelrail.com/learn/monitoring/disk-memory-and-cpu-alerts-that-matter/
Updated: 2026-11-27

Seven alerts cover most small servers: a disk predicted to fill, low filesystem free percent, low available memory, OOM kills, sustained high CPU with load, heavy swap use and a node that stopped reporting. The rules below are starting points. Every number depends on your hardware and workload, so tune each one after you have watched your own graphs for a while.

## How it works

Each rule is a PromQL expression plus a `for` duration, as explained in [alerting without alert fatigue](https://levelrail.com/learn/monitoring/alerting-without-alert-fatigue/)). The metrics come from node_exporter, set up in [Prometheus and node exporter basics](https://levelrail.com/learn/monitoring/prometheus-and-node-exporter-basics/)). Most of these are saturation signals, from [what to monitor first](https://levelrail.com/learn/monitoring/what-to-monitor-first/)), and they fail by running out of something. A fixed threshold is a guess about how much headroom you need, so treat the values below as defaults to change.

## Step 1: Disk predicted to fill

```yaml
- alert: DiskWillFillIn24h
  expr: |
    predict_linear(node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}[6h], 24 * 3600) < 0
  for: 30m
  labels:
    severity: ticket
  annotations:
    summary: "{{ $labels.instance }} root disk predicted to fill within 24h"
```

`predict_linear` fits a line to the last six hours and projects it 24 hours ahead. If the projection is below zero, the disk will fill at the current rate. It handles the fast filler, such as runaway logs, that a plain percentage notices too late. Short windows react quickly but flap, long windows are steady but slow. When it fires, follow [fix a full disk on a Linux server](https://levelrail.com/learn/troubleshooting/fix-a-full-disk-on-a-linux-server/)).

## Step 2: Filesystem free percent

```yaml
- alert: DiskFreeLow
  expr: |
    node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
      / node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"} < 0.10
  for: 15m
  labels:
    severity: page
```

This is the safety net. Ten percent is a conventional starting point. On a very large disk you can go lower, and on a small one you may want a higher figure, because the real question is how many gigabytes it takes to do your next deploy. Also watch inodes with `node_filesystem_files_free` if you store many small files.

## Step 3: Memory available

```yaml
- alert: MemoryAvailableLow
  expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.10
  for: 10m
  labels:
    severity: page
```

Use MemAvailable, which includes reclaimable cache, not MemFree. A server with 5 percent MemFree and 60 percent MemAvailable is healthy. Ten percent available for ten minutes means real pressure. See [check disk, memory and CPU usage](https://levelrail.com/learn/server-basics/check-disk-memory-and-cpu-usage/)) for the command-line view.

## Step 4: OOM kills

```yaml
- alert: OomKillDetected
  expr: increase(node_vmstat_oom_kill[10m]) > 0
  labels:
    severity: page
  annotations:
    summary: "The kernel killed a process for memory on {{ $labels.instance }}"
```

The counter `node_vmstat_oom_kill` increases on every kill, so any increase means something died. It is available when node_exporter's vmstat collector is on, which is the default on recent versions, but confirm it appears in your `/metrics`. You can also confirm from logs with `journalctl -k | grep -i "out of memory"`. The fix path is [fix out-of-memory kills](https://levelrail.com/learn/troubleshooting/fix-out-of-memory-kills-oom/)). Containers can be killed by their own memory limit without the host running short, so check container logs too.

## Step 5: Sustained CPU and load

```yaml
- alert: CpuBusyHigh
  expr: |
    100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90
  for: 20m
  labels:
    severity: ticket

- alert: LoadHigh
  expr: node_load5 / count by (instance) (node_cpu_seconds_total{mode="idle"}) > 2
  for: 20m
  labels:
    severity: ticket
```

CPU at 100 percent for a minute is normal work. Twenty minutes means a runaway job or too little capacity. Load average divided by the number of cores shows how many tasks queue per core, and the right ceiling depends on the workload, so watch your normal range first. Use ticket severity: high CPU alone rarely means users are hurting.

## Step 6: Swap and node down

```yaml
- alert: SwapHeavilyUsed
  expr: |
    (node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes)
      / node_memory_SwapTotal_bytes > 0.5
  for: 30m
  labels:
    severity: ticket

- alert: NodeDown
  expr: up{job="node"} == 0
  for: 3m
  labels:
    severity: page
```

Small amounts of used swap are harmless, since the kernel parks idle pages there. Heavy use for a long time with low available memory signals thrashing. See [add swap space on Ubuntu](https://levelrail.com/learn/server-basics/add-swap-space-on-ubuntu/)). `NodeDown` is the most important rule: if a host is unreachable, every other alert for it is silent. A few minutes of `for` avoids paging on a reboot. Add a rule for a division by zero case if `SwapTotal` is 0, because servers without swap return no data rather than 0.

## Check it worked

Run `promtool check rules` on the file, then trigger each alert safely: stop node_exporter for `NodeDown`, fill a scratch volume for the disk rules, or temporarily lower a threshold on a test machine. Confirm the message reaches your destination with a working runbook link, then restore the real value. Never test a memory alert by actually exhausting a production server.

## Edge cases and gotchas

- **Thresholds are starting points.** A 16 GB box and a 512 MB box need different numbers. Tune from your own graphs.
- **Compare types carefully.** `predict_linear` needs a range vector like `[6h]`, while comparison uses an instant vector.
- **Page versus ticket.** Only page for things that stop users soon: node down, disk nearly full, memory exhausted. The rest can open a ticket.
- **Maintenance and reboots.** A `for` of a few minutes absorbs a normal reboot. Use silences for longer planned work.
- **Containers share host memory.** Host alerts cannot see which container grew. Add container metrics, see [container metrics with cAdvisor and docker stats](https://levelrail.com/learn/monitoring/container-metrics-with-cadvisor-and-docker-stats/)).
- **Missing metrics mean silent rules.** An expression with no data never fires. Alert on `absent()` or on `up` for important jobs.

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Rule never fires in a test | Metric labels differ from the rule | Run the expression in the graph view and adjust labels |
| `parse error: ... expected type range vector` | Missing `[6h]` range on predict_linear | Add the range selector |
| Disk alert fires on `/boot` or `tmpfs` | No filesystem filter | Add `mountpoint` and `fstype!~` filters |
| Constant `DiskWillFillIn24h` after a big deploy | Short-term growth skews the fit | Lengthen the window or the `for` time |
| Memory alert while `free -h` looks fine | Using MemFree instead of MemAvailable | Switch the metric |
| `node_vmstat_oom_kill` missing | Collector disabled or old exporter | Check `/metrics` and the exporter flags |
| NodeDown fires on every reboot | `for` too short | Raise it a few minutes |
| No data for swap rules | Server has no swap | Remove the rule or guard against zero |

## Quick reference

```text
predict_linear(node_filesystem_avail_bytes{mountpoint="/"}[6h], 24 * 3600) < 0
node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.10
increase(node_vmstat_oom_kill[10m]) > 0
up{job="node"} == 0
```

## Related lessons

- [Alerting without alert fatigue](https://levelrail.com/learn/monitoring/alerting-without-alert-fatigue/)): routing and severity for these rules.
- [Fix a full disk on a Linux server](https://levelrail.com/learn/troubleshooting/fix-a-full-disk-on-a-linux-server/)): what to do when the disk alert fires.
- [Fix out-of-memory kills](https://levelrail.com/learn/troubleshooting/fix-out-of-memory-kills-oom/)): handle the OOM alert.
- [Add swap space on Ubuntu](https://levelrail.com/learn/server-basics/add-swap-space-on-ubuntu/)): context for the swap rule.
- [Grafana dashboards for CPU, memory and disk](https://levelrail.com/learn/monitoring/grafana-dashboards-for-cpu-memory-disk/)): graphs to pick thresholds from.

## Next

Add containers in [container metrics with cAdvisor and docker stats](https://levelrail.com/learn/monitoring/container-metrics-with-cadvisor-and-docker-stats/)).

## Frequently asked questions

### What is a good disk space alert threshold?

There is no universal number. A percentage such as 10 to 15 percent free is a common starting point, but a huge disk can run fine at 5 percent while a small one is in trouble at 20. Predicting time to full with predict_linear is more useful than a fixed percentage.

### How do I alert when a disk will fill soon?

Use predict_linear on node_filesystem_avail_bytes over a few hours and alert when the prediction for the next day or so drops below zero, with a for duration so spikes do not fire it.

### Which memory metric should an alert use?

node_memory_MemAvailable_bytes, compared to node_memory_MemTotal_bytes. MemFree ignores reclaimable cache and gives false alarms.

### How do I detect OOM kills?

node_exporter has a counter, node_vmstat_oom_kill, that increases on each OOM kill. You can also search the kernel log for out of memory messages.


## Sources

- [Prometheus querying functions](https://prometheus.io/docs/prometheus/latest/querying/functions/)
- [Prometheus alerting rules](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/)
