Stern tails logs from many Kubernetes pods and containers at once. Color coding and flexible queries help filter workloads without exact pod IDs.
Overview
Stern is a command-line tool for following logs across multiple Kubernetes pods and the containers inside them. Output is color-coded so lines from different sources are easier to scan during debugging.
You can narrow pods with a regular expression or by naming a Kubernetes resource such as deployment/nginx. Supported resource types include pod, replicationcontroller, service, daemonset, deployment, replicaset, statefulset, and job, including API-group-qualified forms like deployment.apps/nginx. When pods are added or removed, tailing updates automatically.
Multi-container pods are handled together; a container flag filters which containers appear, and by default all containers in a pod are followed. Install options include binary downloads, Homebrew, asdf, Krew, and WinGet on Windows.
Configuration can live in ~/.config/stern/config.yaml or another path via flags or STERNCONFIG. Stern supports custom log templates, JSON and raw output modes, label and field selectors, timestamps, log highlighting and exclusion via regex, and limits on concurrent API log requests to reduce cluster load.
Key features
- Tail many pods and containers
- Regex or resource-based queries
- Color-coded log streams
- Custom Go templates and JSON output
- Label and field selectors
- All-namespaces and multi-namespace
- Config file default overrides
- Concurrent log request limits
Use cases
- Debug deployments with many replicas
- Follow logs during rolling updates
- Compare sidecar container output
- Stream JSON logs into jq pipelines
- Troubleshoot API throttling with verbosity