Complex requests with node-exporter
Node-exporter is a popular tool used to collect various system-level metrics from a Linux/Unix server and expose them via HTTP for monitoring and analysis. Below are five complex requests you can make on node-exporter metrics:
1. Calculate average CPU utilization over the last hour for a specific node:
avg_over_time(node_cpu_seconds_total{job="node-exporter", mode="idle"}[1h])
2. Monitor and alert on unusual disk I/O patterns:
absent(rate(node_disk_read_bytes_total{job="node-exporter", device="sda"}[5m]))
OR absent(rate(node_disk_written_bytes_total{job="node-exporter", device="sda"}[5m]))
This query checks if there's no disk I/O activity (reads or writes) on the sda disk for the last 5 minutes. If no data is available, it might indicate an issue, and an alert can be triggered.
3. Identify the top memory-consuming processes on a node:
topk(5, 100 - (node_memory_MemFree_bytes{job="node-exporter"} / node_memory_MemTotal_bytes{job="node-exporter"}) * 100)
This query calculates the memory usage percentage for each process by dividing used memory ("MemTotal - MemFree") by total memory ("MemTotal"). Then, it selects the top 5 processes with the highest memory usage.
4. Calculate network bandwidth utilization over a specific period for a network interface:
irate(node_network_receive_bytes_total{job="node-exporter", device="eth0"}[1h])
This query calculates the incoming network bandwidth rate (bytes per second) for the "eth0" interface over the last hour using the "irate" function.
irate(node_network_transmit_bytes_total{job="node-exporter", device="eth0"}[1h])
This query calculates the outgoing network bandwidth rate (bytes per second) for the "eth0" interface over the last hour using the "irate" function.
5. Monitor and visualize system load and resource utilization trends:
node_load1{job="node-exporter"}
This query retrieves the 1-minute load average for the node, which represents the average number of processes in the run queue or waiting for CPU time over the last minute.
100 - (avg by (instance) (irate(node_cpu_seconds_total{job="node-exporter", mode="idle"}[5m])) * 100)
This query calculates the CPU utilization percentage for each node by subtracting the average idle CPU time from 100%.
node_memory_MemTotal_bytes{job="node-exporter"}
- node_memory_MemFree_bytes{job="node-exporter"}
- node_memory_Buffers_bytes{job="node-exporter"}
- node_memory_Cached_bytes{job="node-exporter"}
This query calculates the used memory by subtracting free memory, buffers, and cached memory from the total memory.