Prompt
logs missing from kubernetes pods
Latest observation
If logs are missing from Kubernetes pods, the issue is usually one of these: the app isn’t writing to stdout/stderr, the pod restarted, the container log rotated, permissions/node issues, or the logging pipeline is filtering/dropping them.
Quick checks
1) Confirm the pod is healthy and running
kubectl get pods -A -o wide
kubectl describe pod <pod-name> -n <namespace>
Look for:
- restarts
- crash loops
- terminated containers
- events about disk pressure, eviction, or mount issues
2) Check current and previous container logs
kubectl logs <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace> --previous
kubectl logs <pod-name> -n <namespace> -c <container-name>
If the app restarted, --previous is often where the logs are.
3) Verify the app logs to stdout/stderr
Kubernetes captures logs from container stdout/stderr, not from arbitrary files unless you ship them separately.
Inside the container, check where the app logs:
kubectl exec -it <pod-name> -n <namespace> -- sh
# then inspect config / log paths
If the app writes to files like /var/log/app.log, those won’t show up in kubectl logs unless:
- you mount and ship them with a sidecar/agent, or
- the app is configured to log to stdout/stderr.
Common causes
App logs to a file instead of stdout/stderr
Fix: configure the app to log to console.
Examples:
- Java: log to console appender
- Node.js: use console transport
- Python: use StreamHandler to stdout
- Nginx/Apache: redirect access/error logs to stdout/stderr
Container restarted and logs rotated away
Kubernetes only keeps current and previous container logs locally, and node log rotation may remove older logs.
Check:
kubectl describe pod <pod-name> -n <namespace>
Look for restart count and termination reason.
Log collection agent issue
If you use Fluent Bit / Fluentd / Vector / Loki / Elasticsearch / Datadog / etc.:
- agent may be down
- filters may exclude namespace/pod labels
- log shipper may not have permissions
- log pipeline may be backpressured
Check agent pods:
kubectl get pods -A | egrep 'fluent|vector|loki|promtail|datadog'
kubectl logs -n <logging-namespace> <agent-pod>
Node-level log issues
Container logs live on the node under paths like:
/var/log/containers//var/log/pods/- runtime-specific paths under
/var/lib/containerd/or/var/lib/docker/
Problems can happen if:
- node disk is full
- kubelet cannot write logs
- log rotation removed them
- node was replaced or drained
Check node status:
kubectl describe node <node-name>
Look for:
- DiskPressure
- MemoryPressure
- eviction messages
Wrong container or namespace
In multi-container pods, kubectl logs may show the wrong container if not specified.
kubectl logs <pod-name> -n <namespace> -c <container-name>
Sidecar / init container confusion
Logs from init containers are not in the main container logs unless queried specifically:
kubectl logs <pod-name> -n <namespace> -c <init-container-name>
If logs are missing from your central logging system but kubectl logs works
Then the issue is in the log shipping pipeline, not Kubernetes itself.
Check:
- Does
kubectl logsshow logs? - Does the node have
/var/log/containers/*.logentries? - Is the collector reading the right files?
- Are labels/filters dropping logs?
- Are timestamps malformed?
- Is multiline parsing failing?
- Is the destination backend accepting data?
Recommended setup
- Log to stdout/stderr
- Use structured JSON logs
- Include timestamps, severity, pod, container, and trace IDs
- Use a DaemonSet log collector
- Ensure rotation and retention are configured
- Monitor node disk usage and collector health
Useful commands
kubectl get events -n <namespace> --sort-by=.lastTimestamp
kubectl describe pod <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace> --timestamps
kubectl logs <pod-name> -n <namespace> --previous --timestamps
If you want, I can help you troubleshoot this step-by-step. If you share:
kubectl describe pod ...kubectl logs ...- whether you use Fluent Bit/Fluentd/Loki/Datadog/etc.
I can narrow down the exact cause.