DEV Community

DevKit
DevKit

Posted on

Monitoring a VPS host with node_exporter: six metrics to watch and five PromQL alerts

Most VPS dashboards show three numbers: CPU, RAM and disk. That is not enough. A server can look calm while a neighbour VM steals CPU time, swap slowly fills up, or the root filesystem grows because of logs. Here are the node_exporter metrics I would watch on a small VPS, how to read them, and five alert rules to start with.

The examples use the free Grafana dashboard VPS Host Overview Lite (ID 25956, Prometheus datasource, with datasource, job and instance variables). Every metric name below comes from its JSON.

Scrape the node

node_exporter serves metrics on port 9100. A minimal Prometheus job:

scrape_configs:
  - job_name: node
    static_configs:
      - targets: ["YOUR_VPS_IP:9100"]
        labels:
          instance: vps-1
Enter fullscreen mode Exit fullscreen mode

The instance label is what the dashboard's $instance variable filters on. With several servers, give each one its own label and check that every host shows up on its own.

Six metrics to watch

1. CPU steal. The share of time the hypervisor gave your CPU to another guest. The JSON has no separate steal panel. The "CPU usage by mode" panel is defined to sum every mode except idle, and steal is one value of the mode label. Query node_cpu_seconds_total{mode="steal"} directly. If steal rises while your own workload has not changed, the problem is the host, not your code.

2. Load average. node_load1, node_load5 and node_load15. A raw load number means little without the core count, so a panel in the JSON divides node_load5 by the number of cores, counted from node_cpu_seconds_total{mode="idle"}. A value near 1 means the run queue equals the number of cores.

3. Memory. Do not read "free" memory as a raw number. Linux uses spare RAM for page cache, so it looks used even when it is not. Use node_memory_MemAvailable_bytes. In the JSON, used memory is defined as MemTotal - MemAvailable.

4. Swap. node_memory_SwapTotal_bytes and node_memory_SwapFree_bytes. Occupancy matters less than the trend. Swap that fills up slowly over days often means a memory leak.

5. Root filesystem. node_filesystem_avail_bytes and node_filesystem_size_bytes, filtered to mountpoint="/" and excluding tmpfs, overlay, squashfs and network filesystems. Without that filter, container and temporary mounts distort the number.

6. Network and disk I/O. rate(node_network_receive_bytes_total[5m]), rate(node_network_transmit_bytes_total[5m]), rate(node_disk_read_bytes_total[5m]) and rate(node_disk_written_bytes_total[5m]). The network panel in the JSON drops lo, veth*, docker* and br-* interfaces so traffic is not counted twice.

The JSON has no inode panel, and none of the rules below cover inodes. If inode exhaustion matters for your filesystem, add it separately.

Five alert rules

The thresholds are starting points, not measured norms. Watch your host for a week and move each threshold so it fires on a real deviation, not on normal work.

groups:
  - name: vps-host
    rules:
      - alert: VpsCpuSteal
        expr: avg by (instance) (rate(node_cpu_seconds_total{mode="steal"}[5m])) * 100 > 10
        for: 15m
      - alert: VpsLoadHigh
        expr: sum by (instance) (node_load5) / count by (instance) (node_cpu_seconds_total{mode="idle"}) > 1
        for: 10m
      - alert: VpsMemoryHigh
        expr: 100 * (1 - sum by (instance) (node_memory_MemAvailable_bytes) / sum by (instance) (node_memory_MemTotal_bytes)) > 90
        for: 10m
      - alert: VpsSwapHigh
        expr: 100 * (node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes) / node_memory_SwapTotal_bytes > 50
        for: 30m
      - alert: VpsRootDiskFull
        expr: 100 - (sum by (instance) (node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs|devtmpfs|fuse[.].*|nfs.*|cifs|smb3|autofs"}) / sum by (instance) (node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs|devtmpfs|fuse[.].*|nfs.*|cifs|smb3|autofs"})) * 100 > 85
        for: 15m
Enter fullscreen mode Exit fullscreen mode

VpsCpuSteal (above 10% for 15 minutes). The for window filters out short spikes. If the alert fires often, raise the threshold rather than disabling it.

VpsLoadHigh (load5 above the core count for 10 minutes). Dividing by cores makes the rule the same on a one-core and an eight-core VPS. The five-minute average smooths out cron bursts.

VpsMemoryHigh (less than 10% available for 10 minutes). It uses MemAvailable, so page cache does not cause false alarms. The 10-minute window ignores short builds and imports.

VpsSwapHigh (over 50% of swap used for 30 minutes). This checks occupancy, not growth. For an early leak signal, add a rule on deriv(node_memory_SwapFree_bytes[1h]). If the host has no swap, SwapTotal is zero, the division gives NaN, and NaN is never greater than 50, so the alert stays silent.

VpsRootDiskFull (over 85% used for 15 minutes). The filesystem filter matches the query in the dashboard JSON. 85% leaves time to clean up before databases or loggers start failing. If the disk fills fast, predict_linear over node_filesystem_avail_bytes gives a better early warning, but that is a separate topic.

What this does not cover

The rules watch host resources, not your application. Service health needs its own metrics and probes. Also, I have not given "normal" values for your hardware, because they depend on the VPS type, the hypervisor's neighbours and your workload.

Summary

For a VPS, watch steal, load relative to cores, available memory, swap, root disk, and network with disk I/O. Set the thresholds from a week of your own data. The dashboard is listed on its Grafana.com page.

If you want a ready-made set with cAdvisor, uptime checks, logs and backups, there is a paid bundle sold through a Telegram shop: t.me/devkit_shop_bot. The free dashboard and rules above stand on their own.

Top comments (0)