CalcSnippets Search
DevOps 3 min read

`kubectl get events --sort-by` Is Still One of the Fastest Ways to See What Actually Just Went Wrong

A practical guide to inspecting Kubernetes events in time order so you can stop guessing why a pod is pending, restarting, or failing before diving into more expensive debugging.

Why this command matters: when something breaks in Kubernetes, people jump straight to logs, YAML, or dashboards. Sometimes the cluster already told you what happened. You just did not look in the right order.

Kubernetes events are often noisy, but they are also one of the cheapest first places to check when a workload is failing, pending, evicted, or repeatedly restarting. The trick is to view them in a way that matches the question you actually care about: what happened most recently?

The basic command

Start here:

kubectl get events --sort-by=.metadata.creationTimestamp

That sorts events by creation time. If you are debugging inside a namespace:

kubectl get events -n my-namespace --sort-by=.metadata.creationTimestamp

This is better than scanning unsorted output and hoping your eyes find the real issue.

Why events are underrated

Many problems are not app-code failures first. They are orchestration or scheduling failures:

  1. image pull errors
  2. insufficient resources
  3. failed mounts
  4. probe failures
  5. CrashLoopBackOff causes

Events often surface these before logs become useful. If the container never started correctly, logs may not tell the full story yet.

What to look for

When reading events, focus on:

  1. Warning types
  2. repeated reasons
  3. scheduling failures
  4. back-off messages
  5. image pull or secret-related errors

If you see repeated image pull failures, that usually points you toward registry credentials, image tag mistakes, or network access rather than application logic.

If you see probe failures, look at readiness and liveness configuration before rewriting code.

Pair it with a specific object

Events are most useful when paired with a concrete pod or deployment investigation.

For example:

kubectl describe pod my-pod -n my-namespace
kubectl get events -n my-namespace --sort-by=.metadata.creationTimestamp

describe gives object-specific detail, while the sorted event stream gives broader context around what the cluster was doing at the same time.

That combination is usually stronger than either command alone.

Why this saves time

A lot of Kubernetes debugging goes wrong because teams start with the most expensive questions:

  1. is the app broken
  2. is the deployment YAML wrong
  3. is the cluster unhealthy
  4. do we need to roll back

Events let you ask the cheaper question first:

what did Kubernetes just report happening?

That is often enough to narrow the problem dramatically.

Narrow the blast radius when a namespace is noisy

Cluster-wide or namespace-wide event output can still be overwhelming on busy systems. If the namespace is noisy, combine this with object inspection so you can line up timing more cleanly:

kubectl get pod my-pod -n my-namespace -o wide
kubectl describe pod my-pod -n my-namespace
kubectl get events -n my-namespace --sort-by=.metadata.creationTimestamp

That sequence helps you answer three useful questions in order:

  1. what node and status does the pod have right now
  2. what object-specific warnings show up in describe
  3. what broader cluster events happened around the same time

This is a much saner first pass than jumping straight into five dashboards and guessing which failure came first.

Final recommendation

When a pod is misbehaving, do not skip straight to heroic debugging. Check the time-sorted event stream first. kubectl get events --sort-by=.metadata.creationTimestamp is still one of the fastest ways to move from vague failure to a more concrete next step.

Sources

Keep reading

Related guides