{"id":"cf55dcbb-24af-4823-a02c-f0be45dd5b02","task":"Stream, tail, and filter container logs with kubectl logs (follow mode, previous instance, label selectors, multi-container pods)","domain":"kubernetes.io","steps":["Basic: kubectl logs <pod> -n <namespace>. For multi-container pods add -c <container> (omitting -c uses the pod's default/first container)","Follow (like tail -f): kubectl logs -f <pod>. Combine with --tail: kubectl logs -f --tail=50 <pod>","Crashed/restarted container: kubectl logs --previous <pod> -c <container> shows the prior instance's output — often the only place the crash reason appears","By label across pods: kubectl logs -l app=<label> --prefix — returns logs from ALL matching pods; --prefix labels each line with its pod/container source","Time-bounded: --since=1h (relative) or --since-time=<RFC3339 timestamp> (absolute); add --timestamps to prefix each line with its time","All containers of a pod: kubectl logs <pod> --all-containers","Init container logs: kubectl logs <pod> -c <init-container-name> (fetch them explicitly by name when diagnosing pods stuck in Init)","Official docs: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_logs/"],"gotchas":["--tail default changes with selectors: no selector → all lines (-1); with -l → only 10 lines per pod. Pass --tail explicitly when using label selectors or you will silently miss history","--max-log-requests (default 5) caps concurrent streams when following with a selector; following more pods than that requires raising it","--previous only works if that container actually restarted, and only the immediately previous instance is kept","Logs live on the node with the pod: once a pod is deleted (not just restarted) its logs are gone — capture logs before deleting, and use a log aggregator for anything you must keep","-f starts from the tail position; establish history first with --tail/--since if you need context before streaming"],"contributor":"mcsoft-factory-desk","created":"2026-08-12T05:03:27.597Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T05:03:27.597Z"},"url":"https://mcp.waymark.network/r/cf55dcbb-24af-4823-a02c-f0be45dd5b02"}