Check Node CPU Utilization in OpenShift
In this article
To check node CPU utilization in OpenShift, you can use the built-in metrics stack (Prometheus and Grafana) or the command-line tools oc and top commands. The quickest way is to run oc adm top nodes which shows live CPU and memory usage per node. This guide covers both the web console and CLI methods, plus how to interpret the numbers and troubleshoot common issues.
What You'll Need
- Access to an OpenShift cluster (version 4.x) with cluster-admin or a role that allows viewing node metrics (e.g.,
viewon nodes). - The OpenShift CLI (
oc) installed and logged in (oc login). - Cluster monitoring must be enabled (default in most installs). If metrics are not available, you'll see errors when running
oc adm top nodes.
Step-by-Step
- Check CPU usage via CLI (quick method)
Run the following command to see CPU and memory usage per node:
oc adm top nodes
The output shows columns: NAME, CPU(cores), CPU%, MEMORY(bytes), MEMORY%. The CPU% is the percentage of total allocatable CPU on that node. For example, a node with 8 cores showing 2000m (2 cores) will display 25%. - Check CPU usage per pod (if you need to see which pods are consuming)
Runoc adm top pods --all-namespacesto see CPU usage per pod across all projects. Add-l 'app=myapp'to filter by label. - Use the web console
In the OpenShift web console, go to Observe → Metrics. Select Node as the query type and choose a metric likenode_cpu_seconds_total(total CPU seconds) orinstance:node_cpu_utilisation:rate5m(5-minute average utilization). You can also go to Compute → Nodes, click a node, and view the Metrics tab for a graphical view of CPU usage. - Use Prometheus queries (for deeper analysis)
In the console's Metrics page, you can run PromQL queries. For example, to see average CPU utilization per node over 5 minutes:
instance:node_cpu_utilisation:rate5m
To see per-core usage:rate(node_cpu_seconds_total{mode="user"}[5m]). You can also create custom dashboards in Grafana (if installed) using similar queries. - Check node conditions and allocatable resources
Runoc describe nodeto see the node's capacity and allocatable CPU. This helps you understand what the CPU% intopis based on. For example, if a node has 8 cores but only 7 are allocatable (due to system reservations), the percentage is calculated against 7. - Set up alerts (if needed)
To be notified when CPU usage is high, you can create a Prometheus alert rule. In the console, go to Observe → Alerting → Alerting rules, and create a rule with a query likeinstance:node_cpu_utilisation:rate5m > 0.8(80% utilization).
Common Mistakes
- Misreading CPU%: The CPU% in
oc adm top nodesis relative to the node's allocatable CPU, not the total physical cores. If you have reserved CPU for system daemons, the percentage can be higher than expected. - Using the wrong query:
node_cpu_seconds_totalis a counter, not a gauge. You must userate()orirate()to get a utilization percentage. Without it, you'll see an ever-increasing number. - Forgetting to specify namespace: When checking pod CPU, if you run
oc adm top podswithout--all-namespaces, you only see pods in the current project. Use-Aor--all-namespacesto see all. - Assuming the CLI is installed: If
ocis not installed, you can still use the web console, but the CLI is often faster. Install it from the cluster's help menu.
Tips
- Use
watch oc adm top nodesto refresh the output every 2 seconds, which helps spot spikes. - To see CPU usage per container, use
oc adm top pods --containers. - For historical data, use the built-in Grafana dashboards (if enabled) or create a Prometheus query with a time range selector, e.g.,
instance:node_cpu_utilisation:rate5m[1h]. - If you see high CPU on a node but no obvious pods, check for system processes or infrastructure pods (like router or registry) that might be consuming resources.
- Remember that CPU requests and limits are not the same as usage. A pod can request 1 core but only use 0.1 core; the usage is what
topshows.
Troubleshooting
If oc adm top nodes returns an error like "metrics not available yet": This usually means the metrics stack is not fully initialized. Wait a few minutes and try again. If it persists, check that the openshift-monitoring namespace is running: oc get pods -n openshift-monitoring. If pods are not running, check the cluster's health.
If the output shows 0% for all nodes: This can happen if the metrics are not being scraped correctly. Check the Prometheus targets in the console (Observe → Metrics → Targets) to see if any are down. Also verify that the node exporter is running on each node: oc get daemonset -n openshift-monitoring.
If you cannot see the Metrics tab in the console: Ensure your user has the cluster-monitoring-view role. You can add it with: oc adm policy add-cluster-role-to-user cluster-monitoring-view .
If the web console shows no data: Try clearing your browser cache or using an incognito window. Also check that the time range is set correctly (e.g., last 15 minutes).
Frequently Asked Questions
What is the difference between CPU usage and CPU utilization?
CPU usage is the actual amount of CPU time consumed (in cores or milliseconds). CPU utilization is that usage expressed as a percentage of the total available CPU. For example, a node with 4 cores using 2 cores has 50% utilization.
How do I see CPU usage per project?
You can run oc adm top pods --all-namespaces and then group the output by project, or use a Prometheus query like sum(rate(container_cpu_usage_seconds_total{namespace!=""}[5m])) by (namespace).
Why does the CPU% in oc adm top nodes sometimes exceed 100%?
It shouldn't. If it does, it might be due to a bug or because the node has overcommitted resources (e.g., using burstable QoS). The percentage is based on allocatable CPU, so it should not exceed 100% in normal operation. If it does, check for misconfigured node labels or a corrupted metrics cache.
Can I check CPU usage on a specific node only?
Yes, use oc adm top node to see a single node's usage.
Does the web console show real-time data?
The console shows data with a slight delay (usually 30-60 seconds) because metrics are scraped at intervals. For near-real-time, use the CLI with watch.
What should I do if a node is consistently at 100% CPU?
First, identify which pods are consuming the CPU using oc adm top pods --all-namespaces. Then, consider scaling the workload, increasing node size, or adding more nodes. Also check for CPU throttling due to limits.