| name | analyzing-k8s-events |
| description | Analyzes Kubernetes cluster events to understand what happened and when. Use when investigating incidents, checking warnings, building event timeline, or understanding cluster activity. |
| allowed-tools | Bash |
Analyzing Kubernetes Events
Investigates cluster and namespace events to build timeline and identify issues.
Quick Event Commands
kubectl get events -n <ns> --sort-by=.lastTimestamp
kubectl get events -A --sort-by=.lastTimestamp | head -50
kubectl get events -n <ns> --field-selector type=Warning
kubectl get events -n <ns> --sort-by=.lastTimestamp | head -30
Filtering Events
By Resource
kubectl get events -n <ns> --field-selector involvedObject.name=<pod>
kubectl get events -n <ns> --field-selector involvedObject.name=<deployment>,involvedObject.kind=Deployment
kubectl get events -n <ns> --field-selector involvedObject.kind=PersistentVolumeClaim
By Type
kubectl get events -n <ns> --field-selector type=Warning
kubectl get events -n <ns> --field-selector type=Normal
By Reason
kubectl get events -A --field-selector reason=Failed
kubectl get events -A --field-selector reason=FailedScheduling
kubectl get events -A --field-selector reason=FailedMount
kubectl get events -A --field-selector reason=BackOff
kubectl get events -A --field-selector reason=Unhealthy
kubectl get events -A --field-selector reason=OOMKilling
Common Event Reasons
| Reason | Meaning | Action |
|---|
| FailedScheduling | No node can run pod | Load debugging-k8s-scheduling |
| FailedMount | Volume mount failed | Load debugging-k8s-storage |
| BackOff | Container crashing | Load debugging-k8s-pods |
| Unhealthy | Probe failing | Check liveness/readiness probe |
| Killing | Pod being terminated | Check termination reason |
| Pulled | Image pulled successfully | Informational |
| Created | Container created | Informational |
| Started | Container started | Informational |
Event Timeline Analysis
Build Timeline for Incident
kubectl get events -n <ns> --sort-by=.lastTimestamp -o wide
kubectl get events -n <ns> --sort-by=.lastTimestamp \
-o custom-columns=TIME:.lastTimestamp,TYPE:.type,REASON:.reason,OBJECT:.involvedObject.name,MESSAGE:.message
Correlate Events Across Resources
kubectl get events -n <ns> -o json | jq '.items[] | select(.message | contains("<search-term>"))'
kubectl get events -n <ns> --sort-by=.lastTimestamp -o wide | grep <term>
Event Details
kubectl get events -n <ns> --field-selector involvedObject.name=<resource> -o json
Event Retention
Events are stored in etcd with limited retention (default ~1 hour). For older events:
- Check logging system (if deployed)
- Check monitoring/alerting history
- Events are ephemeral, don't rely on them for long-term history
Quick Investigation Pattern
kubectl get events -n <ns> --field-selector type=Warning --sort-by=.lastTimestamp
kubectl get events -n <ns> --field-selector involvedObject.name=<resource> --sort-by=.lastTimestamp
kubectl describe <resource-type> <resource-name> -n <ns>
Notes
- Events are ephemeral (typically 1 hour retention)
- Warning type events indicate problems
- Normal type events are informational
- After identifying issue type, load specialized skill for deeper investigation