- Prometheus UI at
http://localhost:9090— use the “Graph” tab for ad-hoc exploration. - Grafana Explore — go to Explore, select the Prometheus datasource, and type your query.
Example queries
- CPU
- Memory
node_cpu_seconds_total{mode="idle"}— selects thenode_cpu_seconds_totalmetric and filters it to only theidlemode using a label selector. Node Exporter reports CPU time broken down by mode (idle, user, system, etc.).rate(...[1m])— computes the per-second rate of increase over a 1-minute sliding window. This smooths out short spikes and accounts for the counter always increasing.avg(...)— averages the idle rate across all CPU cores, giving a single value that represents the machine as a whole.* 100— converts the fraction (0–1) to a percentage (0–100).100 - (...)— flips idle percentage to usage percentage. If 20% of CPU time is idle, then 80% is in use.
Prometheus scrapes Node Exporter every 15 seconds in this project. The
rate() window must be significantly larger than the scrape interval, so [1m] gives Prometheus at least 4 data points to work with. Using [15s] or smaller would produce unreliable results.Exploring available metrics
To see all metrics that Prometheus is collecting, open the Prometheus UI athttp://localhost:9090 and click the metrics explorer icon next to the query input. You can also browse to http://localhost:9090/metrics on the Node Exporter directly to see the raw output.
To list all metrics exposed by Node Exporter, filter by job in the Prometheus UI:
node-exporter target.
Filtering with labels
Labels are key-value pairs attached to every metric. You can filter any query by adding a label selector inside{}.
To target a specific job:
{}:
Adding a PromQL panel to a Grafana dashboard
To visualize a PromQL query as a panel on a Grafana dashboard:- Open Grafana at
http://localhost:3000and navigate to your dashboard. - Click Add → Visualization.
- In the Data source dropdown, select Prometheus.
- Enter your PromQL query in the query field, for example:
- Choose a visualization type (Time series, Gauge, Stat, etc.) from the panel type selector.
- Click Apply to save the panel to the dashboard.