Stern — Multi-Pod Multi-Container Log Tailing for Kubernetes
The missing multi-Pod tail -f for Kubernetes. Follows every matching Pod and container with color-coded names — the first tool SREs install after kubectl.
What it is
Stern is a CLI tool that tails logs from multiple Kubernetes pods and containers simultaneously. It shows color-coded output with pod and container names, making it easy to follow distributed application logs in real time.
Stern targets SREs, DevOps engineers, and developers debugging Kubernetes workloads. It solves the problem of running multiple kubectl logs -f commands in separate terminals by combining all matching logs into a single stream.
The project is actively maintained and suitable for both individual developers and teams looking to integrate it into their existing toolchain. Documentation and community support are available for onboarding.
How it saves time or tokens
Instead of opening one terminal per pod and mentally correlating timestamps, Stern shows all matching pods in one view with color-coded prefixes. Pod selectors use regex, so you can tail all pods for a deployment with a single pattern. When pods restart or scale, Stern automatically picks up new instances without reconnecting.
How to use
- Install Stern via Homebrew (
brew install stern), Krew, or download the binary from GitHub releases. - Run
stern <pod-name-pattern>to tail all pods matching the pattern in the current namespace. - Use flags to filter by container name, namespace, label selector, or time range.
- Pipe output to grep or jq for structured log filtering.
Example
# Tail all pods matching 'web-api' in the production namespace
stern web-api --namespace production
# Tail specific container in pods with label selector
stern --selector app=gateway --container nginx
# Show logs from the last 10 minutes in JSON format
stern payment-service --since 10m --output json | jq '.message'
# Tail across all namespaces
stern web --all-namespaces
Related on TokRepo
- AI Tools for DevOps — Other Kubernetes observability and debugging tools.
- AI Tools for Monitoring — Log aggregation and monitoring solutions for production clusters.
Common pitfalls
- Using broad regex patterns in large clusters. A pattern like
.*tails every pod and overwhelms your terminal. Be specific with pod name patterns. - Forgetting the
--sinceflag when debugging. Without it, Stern shows logs from pod start time, which can dump megabytes of old logs. - Not using
--excludeto filter out health check noise. Most services log health check requests every few seconds, cluttering the output. - Not reading the changelog before upgrading. Breaking changes between versions can cause unexpected failures in production. Pin your version and review release notes.
Frequently Asked Questions
kubectl logs follows one pod at a time and requires a separate command per container. Stern tails multiple pods matching a regex pattern with color-coded output. It also auto-detects new pods as they scale up or restart.
Yes. Stern uses the standard Kubernetes API for log streaming. It works with any conformant distribution including EKS, GKE, AKS, k3s, and minikube.
Stern does not parse log content natively. Pipe its output to grep for text matching or jq for JSON-structured logs. For example: `stern app --output json | jq 'select(.level == "error")'`.
Yes. The `--output json` flag wraps each log line in a JSON envelope with pod name, container name, namespace, and timestamp. You can then process this with jq or feed it to a log aggregator.
On macOS use `brew install stern`. On Linux download the binary from the GitHub releases page. If you use Krew (kubectl plugin manager), run `kubectl krew install stern`.
Citations (3)
- Stern GitHub— Multi-pod log tailing for Kubernetes
- Stern README— Regex-based pod selection and color-coded output
- Kubernetes Docs— Kubernetes log streaming API
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.