Multi-pod Kubernetes log tailer with regex filtering and color-coded output for container debugging
Stern is a Kubernetes log tailing tool that allows you to simultaneously monitor logs from multiple pods and containers. It uses regular expressions to filter pod names, eliminating the need to specify exact deployment IDs, and automatically handles pod lifecycle changes by removing deleted pods and adding new ones to the tail stream.
The tool provides color-coded output to distinguish between different pods and containers, making it easier to debug multi-container deployments. You can filter logs using regular expressions with flags like --include, --exclude, and --highlight, and target specific containers within pods using the --container flag. Stern supports querying pods by Kubernetes resources (deployment/nginx) or regex patterns (web-\w).
Stern integrates with standard Kubernetes tooling, respecting kubeconfig contexts and namespace settings. It offers multiple output formats including raw logs for piping to tools like jq, JSON output for programmatic use, and customizable Go templates. The tool supports advanced filtering by labels, field selectors, container states, and node names, while providing options for timestamp formatting and timezone control.
# via Homebrew
brew install stern
# via Go
go install github.com/stern/stern@latest
# via Krew
kubectl krew install stern