Interview Prep/Monitoring & Observability/Logging: ELK/EFK, Loki & Log Shippers

How do Kubernetes container logs get from the app to a log backend?

BeginnerConceptLogging: ELK/EFK, Loki & Log Shippers
Answer
  1. The app writes to stdout/stderr.
  2. The container runtime (containerd/CRI-O) writes it to /var/log/pods/<ns>_<pod>_<uid>/<container>/0.log in CRI format (timestamp stream flag message), symlinked from /var/log/containers/.
  3. The kubelet rotates these files (containerLogMaxSize, default 10Mi, containerLogMaxFiles, default 5).
  4. A DaemonSet agent (Fluent Bit, Alloy, OTel Collector filelog receiver) tails them, enriches with metadata and ships to Loki/Elasticsearch/CloudWatch.

kubectl logs reads the same files via the kubelet.

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Logging: ELK/EFK, Loki & Log Shippers