By Krust··8 min read

Kubernetes Pod Metrics: Use Prometheus Before You Restart

An evidence-first workflow for reading Kubernetes CPU and memory signals, checking Prometheus trends, and deciding whether a restart will fix anything.

kubernetesprometheustroubleshootingmetrics
Krust pod inspector showing Prometheus CPU and memory metrics for a Kubernetes workload

A Pod using 900 millicores is not automatically unhealthy. A Pod using 300 millicores can still be the one causing an incident. The number only becomes useful when you connect it to requests, limits, restarts, latency, rollout timing, and the shape of the trend.

Use the Kubernetes Metrics API to find where to look. Use Prometheus to understand what changed over time. Then read resource state, Events, and logs before you restart anything.

TL;DR

  1. Find the Pod or workload whose current CPU or memory differs from its peers.
  2. Compare usage with requests, limits, restart count, and readiness.
  3. Read a Prometheus range for the period before and during the symptom.
  4. Correlate the change with a rollout, traffic shift, probe failure, or OOM event.
  5. Inspect Events and previous container logs.
  6. Restart only when the evidence says replacement is the recovery action—not because a chart looks high.

Metrics narrow the investigation. They do not identify root cause by themselves.

What do Kubernetes metrics tell you?

The Kubernetes resource metrics pipeline provides recent CPU and memory usage for nodes and Pods through the metrics.k8s.io API. Tools such as kubectl top use the same API.

That snapshot is good for triage:

kubectl top pods -n production --containers
kubectl get pods -n production -o wide

Read the outputs together. A useful first pass asks:

  • Is one replica materially different from the others?
  • Did usage change after a new ReplicaSet appeared?
  • Is the Pod Ready?
  • Is the container restarting?
  • Is current usage close to a configured request or limit?
  • Is the value stable, rising, or already falling?

The Metrics API does not provide the historical context needed for the last question. That is where Prometheus earns its place.

When should you switch from metrics-server to Prometheus?

Switch when the question contains time:

  • “Did memory start growing after the rollout?”
  • “Was CPU already high before the alert?”
  • “Did every replica spike, or only one?”
  • “Did usage recover before the Pod restarted?”
  • “Is this a sustained trend or a short burst?”

Prometheus instant queries answer a point-in-time question. Range queries return samples across an interval. Do not request a range when you only need “now,” and do not infer a trend from one sample.

The practical split is:

Signal Best use
metrics-server current value Find the hot Pod or workload quickly
Prometheus instant query Compare replicas at one moment
Prometheus range query Confirm growth, spikes, recovery, or rollout correlation
Pod status and Events Explain readiness, scheduling, probe, and OOM behavior
Current and previous logs Explain application or container failure

How do you investigate high CPU without guessing?

Start with scope. If every replica rises together, investigate shared traffic, a downstream dependency, or a new release. If one replica is different, inspect that Pod’s node, requests, container state, logs, and request distribution.

Then look at the shape:

  • Short spike, fast recovery: often burst work, startup, compaction, or a scheduled task.
  • Sustained plateau: may be steady load, a tight loop, throttling, or insufficient replicas.
  • Step change at rollout: compare the old and new ReplicaSets and their revisions.
  • Sawtooth pattern: can be normal batch behavior, garbage collection, or repeated retries.

Do not diagnose throttling from CPU usage alone. You need the relevant throttling counter and the container’s CPU limit. Do not diagnose a leak from one rising segment. Extend the time window and compare against traffic and restarts.

How do you investigate memory pressure?

Memory requires a different mental model. CPU can drop immediately when work stops. Process memory may remain allocated even when the application is healthy.

Check these signals in order:

  1. Does memory keep rising across a meaningful interval?
  2. Is the growth isolated to one replica or shared by the workload?
  3. Is the container approaching its memory limit?
  4. Did the last termination report OOMKilled?
  5. Do previous logs show the work immediately before termination?
  6. Did a rollout, cache warm-up, or traffic change start the trend?

If a container was OOM-killed, the restart is already an outcome. The investigation is why memory crossed the limit. Increasing the limit may restore service, but it is not evidence that the limit was the root cause.

For a crash loop, follow the fuller previous-logs workflow before changing probes or limits.

How does Krust connect Prometheus to live Pod evidence?

Krust keeps two paths separate:

  • resource tables poll metrics-server for current CPU and memory columns
  • a selected Pod inspector can query recent Prometheus CPU and memory series

Configure an in-cluster Prometheus Service in Settings → Observability. Choose the context, namespace, Service, port or named port, and scheme, then run Check connection.

Krust sends the query through the Kubernetes API Service proxy. Prometheus does not need a public endpoint or a manual port-forward. The active kubeconfig identity still needs permission to access the Service proxy.

Per-context profiles matter when clusters expose Prometheus under different namespaces or Service names. The selected cluster remains explicit instead of reusing one endpoint across every context.

When Prometheus is unavailable, the inspector reports the connection problem and the resource view continues to work. Current metrics-server values, Pod state, Events, and logs remain independent evidence paths.

See the exact setup and failure states in the Krust metrics documentation.

A complete evidence path

Suppose api-7f9d8 shows higher memory than its peers.

  1. Open the Deployment and confirm which ReplicaSet owns the Pod.
  2. Compare current usage across replicas.
  3. Open the Pod inspector and read the Prometheus memory trend.
  4. Check whether the increase began at rollout time.
  5. Read container state, last termination reason, and warning Events.
  6. Open previous logs if the container restarted.
  7. Compare the live workload revision with the previous revision.
  8. Decide whether the durable fix belongs in code, configuration, resource limits, or replica count.

That path produces a testable statement: “memory began rising only on the new ReplicaSet, crossed the container limit, and the previous container was OOM-killed.” It is more useful than “the Pod looked hot, so we restarted it.”

Common wrong moves

  • Restarting the highest-CPU Pod: high usage can be healthy work.
  • Reading only averages: averages hide one bad replica and short spikes.
  • Treating requests as limits: they serve different scheduling and enforcement roles.
  • Calling any rising memory line a leak: first extend the interval and correlate it.
  • Opening a broad dashboard before selecting the workload: start from the affected resource and widen only when needed.
  • Ignoring previous logs: the current container cannot explain what the previous process did before termination.

FAQ

Does Kubernetes include historical Pod metrics?

The resource Metrics API provides recent CPU and memory values for autoscaling and quick inspection. Historical analysis requires a time-series system such as Prometheus.

Does a high CPU percentage mean the Pod needs more CPU?

Not by itself. Compare usage with limits, throttling signals, latency, work rate, and peer replicas. The same CPU value can mean productive work or a failure loop.

Should Prometheus be exposed outside the cluster?

Krust does not require that for its inspector charts. It can access an in-cluster Prometheus Service through the Kubernetes API Service proxy using the current kubeconfig identity.

Sources