CKA Troubleshooting Practice Question
Which command lists all events in the cluster sorted by timestamp?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
kubectl get events --sort-by=.metadata.creationTimestamp
'kubectl get events --sort-by=.metadata.creationTimestamp' shows events sorted by creation time. Alternatively, 'kubectl get events -w' watches events but does not sort.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl get events --watch
Why it's wrong here
`kubectl get events --watch` establishes a long-lived request to the API server that streams subsequent event changes, but it does not apply any client-side sort to the initial list. The initial list is returned in the API server's default ordering (typically by resourceVersion), and new events appear as they arrive, so the output is not ordered by creationTimestamp. To sort, you must supply an explicit `--sort-by` flag rather than relying on the watch stream.
- ✗
kubectl logs --events
Why it's wrong here
The `--events` flag is not a valid option for `kubectl logs`; container log output is read from the pod's container runtime, not from the Kubernetes API event store. Running this command fails with an unknown-flag error, and even if the flag existed it would not provide cluster-wide event history. Events are separate API objects and must be queried using `kubectl get events` or `kubectl describe`.
- ✗
kubectl describe events
Why it's wrong here
`kubectl describe events` presents events in a human-readable text format, but the `describe` subcommand does not accept `--sort-by` and does not reorder the event list. Its default output groups by object and summarizes repeated occurrences with a count, so events are not arranged chronologically across the cluster. For deterministic time-based ordering you need `kubectl get` with a JSONPath sort expression.
- ✓
kubectl get events --sort-by=.metadata.creationTimestamp
Why this is correct
This is the correct command because `kubectl get` supports the `--sort-by` flag, which takes a JSONPath expression evaluated against each returned object. Here `.metadata.creationTimestamp` is the standard field that records when each event object was created, and the client sorts all events by that timestamp before printing them, giving chronological order. Combining the `events` resource with this sort key is the direct, supported way to list all events sorted by time.
Go deeper
Related to this question
About these practice questions
This CKA question is part of Courseiva's 726-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.