stern
Multi-pod Kubernetes log tailing
TLDR
Tail pod logs
SYNOPSIS
stern [-n namespace] [-c container] [--since duration] [options] pod-query
DESCRIPTION
stern allows you to tail log output from multiple Kubernetes pods and containers simultaneously. It accepts a pod name query (which can be a regular expression) and streams log lines from all matching pods, automatically including new pods as they appear and removing terminated ones.
Each pod and container is assigned a distinct color in the output, making it easy to visually distinguish which log lines come from which source. Stern supports filtering by namespace, container name, and label selectors, and can output logs in various formats including JSON for structured processing.
The tool is particularly useful for debugging microservices where related functionality spans multiple pods or deployments. Unlike `kubectl logs`, which can only follow a single pod at a time, stern aggregates logs across any number of matching pods and gracefully handles pod restarts and scaling events in real time.
PARAMETERS
-n, --namespace NS
Kubernetes namespace.--all-namespaces, -A
All namespaces.-c, --container NAME
Container name.--since DURATION
Logs since duration.-t, --timestamps
Show timestamps.-o, --output FORMAT
Output format.-s, --selector SELECTOR
Label selector.--tail N
Lines per container.
CAVEATS
Requires kubectl access. Many pods may overwhelm. Network latency affects streaming.
HISTORY
stern was created by Wercker (now Oracle) for Kubernetes log tailing. It simplifies viewing logs from multiple pods simultaneously.
