Prompt
How do I troubleshoot log ingestion failures from Kubernetes?
Latest observation
Here’s a practical way to troubleshoot log ingestion failures from Kubernetes, ordered from fastest checks to deeper debugging.
1) Confirm the failure is real
Start by determining whether logs are missing because of:
- No logs being produced
- Agent can’t read container logs
- Agent is running but not shipping
- Backend is rejecting or dropping logs
- Parsing/routing issues make logs appear missing
Quick checks:
kubectl logs <pod> -n <ns>
kubectl get pods -A
kubectl get events -A --sort-by=.metadata.creationTimestamp
If the app itself has no logs, ingestion won’t help.
2) Check the logging agent status
Identify your log collector:
- Fluent Bit
- Fluentd
- Vector
- Filebeat
- OpenTelemetry Collector
- Vendor agents like Datadog, Splunk, New Relic, etc.
Check that it is deployed and healthy:
kubectl get ds -A
kubectl get deploy -A
kubectl get pods -A | grep -i 'fluent\|vector\|otel\|filebeat\|log'
Then inspect pod health:
kubectl describe pod <collector-pod> -n <ns>
kubectl logs <collector-pod> -n <ns>
Look for:
- CrashLoopBackOff
- OOMKilled
- permission denied
- connection refused
- TLS/cert errors
- authentication failures
- buffer full / retry limit reached
3) Verify the agent can access Kubernetes log files
Most Kubernetes logging agents read container logs from the node filesystem, usually via:
/var/log/containers/var/log/pods/var/lib/docker/containerson older setups
If the agent runs as a DaemonSet, ensure it has:
hostPathmounts to those directories- correct
securityContext - permission to read the files
Example checks:
kubectl get ds <collector> -n <ns> -o yaml
Look for volume mounts like:
hostPath:
path: /var/log
Common issues:
- Missing hostPath mount
- Wrong path on container runtime
- Insufficient permissions
- SELinux/AppArmor restrictions
4) Validate node-level access and runtime compatibility
Different runtimes and distros can affect paths and permissions.
Check:
kubectl get nodes -o wide
kubectl describe node <node>
Confirm:
- container runtime is supported
- the agent supports your runtime (
containerd,CRI-O, Docker legacy) - log format matches expectations
- symlinks under
/var/log/containersare intact
For containerd, logs are typically under:
/var/log/pods/...- symlinks in
/var/log/containers/...
5) Check for resource pressure or dropped logs
Logs may be lost if the agent is starved or backpressure occurs.
Inspect:
kubectl top pods -A
kubectl top nodes
Look for:
- CPU throttling
- memory limits too low
- node disk pressure
- container restarts
Also inspect collector metrics if exposed:
- dropped records
- retries
- buffer queue length
- output failures
6) Inspect collector configuration
Misconfiguration is a top cause.
Things to verify:
- Input path matches actual log location
- Namespace/pod filters aren’t excluding logs
- Regex/parsers are correct
- Multiline configuration is valid
- Time formats parse correctly
- Output endpoint is correct
- Index/stream/tenant names are valid
- Labels/metadata enrichment doesn’t fail
Common symptoms:
- logs exist locally but not in backend
- only certain namespaces are missing
- only JSON or multiline logs fail
- logs arrive but fields are malformed
7) Test network connectivity to the backend
If the agent ships to Elasticsearch, Loki, Splunk, CloudWatch, Datadog, etc., check connectivity from the collector pod.
kubectl exec -it <collector-pod> -n <ns> -- sh
Then test:
nslookup <log-endpoint>
curl -vk https://<log-endpoint>
Watch for:
- DNS failures
- proxy issues
- firewall / NetworkPolicy blocks
- TLS handshake errors
- certificate trust issues
- 401/403 auth problems
- 429 rate limits
If NetworkPolicies are used:
kubectl get networkpolicy -A
8) Check authentication and authorization
If logs fail at the backend, credentials may be wrong or expired.
Examples:
- API key invalid
- IAM role missing permissions
- service account token issues
- secret not mounted or rotated
- tenant/org mismatch
Inspect secrets and environment variables used by the collector:
kubectl describe pod <collector-pod> -n <ns>
kubectl get secret -n <ns>
9) Look for backend-side rejections
Sometimes the collector is fine but the destination rejects logs.
Examples:
- payload too large
- schema/format invalid
- rate limiting
- index template mismatch
- retention or quota exceeded
Check destination logs/metrics if available, and collector output logs for response codes.
10) Confirm app log format isn’t breaking ingestion
Some log formats are tricky:
- multiline Java stack traces
- JSON lines with embedded newlines
- partial writes
- very large lines
- non-UTF-8 bytes
If multiline parsing is wrong, logs may:
- split incorrectly
- be dropped
- appear delayed
- be merged with other entries
Try a simple test log from a pod:
kubectl run logtest --image=busybox -n <ns> --restart=Never -- sh -c 'echo test-log && sleep 3600'
kubectl logs logtest -n <ns>
If simple logs ingest but app logs don’t, focus on parsing.
11) Check Kubernetes metadata enrichment
If your pipeline enriches logs with pod labels/annotations, failures there can cause drops or missing routing.
Possible problems:
- RBAC missing for listing/watching pods/nodes/namespaces
- API server unreachable
- excessive metadata calls
- invalid label keys causing pipeline errors
Check collector RBAC:
kubectl auth can-i list pods --as system:serviceaccount:<ns>:<sa> -n <ns>
kubectl auth can-i watch pods --as system:serviceaccount:<ns>:<sa> -n <ns>
12) Debug with a minimal test path
If the problem is unclear, isolate it:
- Deploy a simple pod that writes known logs.
- Confirm logs appear in
kubectl logs. - Confirm collector sees the file on the node.
- Reduce collector config to a minimal input/output.
- Send to a test index/stream/tenant.
This helps determine whether the issue is:
- source
- collector
- transport
- backend
Common root causes checklist
- Collector pod crashing or OOMing
- Missing or wrong hostPath mounts
- Wrong log path for container runtime
- RBAC permissions missing
- NetworkPolicy blocking egress
- TLS/certificate errors
- Invalid auth credentials
- Parser/multiline misconfiguration
- Backend rate limit or quota exceeded
- Disk pressure causing node log loss
- Logs rotated before being collected
- Sidecar/app writes to stdout/stderr incorrectly
What to collect for deeper troubleshooting
If you escalate or need vendor support, gather:
- Collector logs:
kubectl logs <collector-pod> -n <ns> --previous kubectl logs <collector-pod> -n <ns> - Collector config:
kubectl get configmap,secret -n <ns> - Pod spec:
kubectl get pod <collector-pod> -n <ns> -o yaml - DaemonSet/Deployment:
kubectl get ds,deploy -n <ns> -o yaml - Node info:
kubectl describe node <node> - Events:
kubectl get events -A --sort-by=.metadata.creationTimestamp - Backend response/error messages
Fastest path to isolate the issue
If you want the shortest troubleshooting flow:
- Check collector pod logs
- Verify hostPath mounts
- Confirm backend connectivity
- Check auth/TLS errors
- Test with a simple pod log
- Inspect parser/multiline config
- Look at resource limits and dropped-log metrics
If you want, I can give you a vendor-neutral Kubernetes log troubleshooting runbook or a Fluent Bit-specific checklist.