How do Kubernetes container logs get from the app to a log backend?
BeginnerConceptLogging: ELK/EFK, Loki & Log Shippers
Answer
- The app writes to stdout/stderr.
- The container runtime (containerd/CRI-O) writes it to
/var/log/pods/<ns>_<pod>_<uid>/<container>/0.login CRI format (timestamp stream flag message), symlinked from/var/log/containers/. - The kubelet rotates these files (
containerLogMaxSize, default 10Mi,containerLogMaxFiles, default 5). - 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.
More on Logging: ELK/EFK, Loki & Log Shippers
What is the ELK stack, and what is EFK?BeginnerHow does Elasticsearch store and search logs?IntermediateWhat is ILM (Index Lifecycle Management) and why do log clusters need it?IntermediateWhat is an Elasticsearch data stream?AdvancedWhat is an index template and mapping, and what is a mapping explosion?AdvancedWhat does Logstash do compared with Beats?Intermediate