Kubernetes log tailing tool that aggregates logs from multiple pods and containers with regex filtering and color coding
Stern is a Kubernetes log aggregation tool that allows you to tail logs from multiple pods and containers simultaneously. Unlike kubectl logs which handles one pod at a time, Stern uses regular expressions to match pod names, automatically discovering and following logs from all matching pods. When pods are deleted or created, Stern dynamically adjusts its log streams without manual intervention.
The tool provides regex-based filtering for both pod selection and log content. You can specify container patterns to limit which containers within pods to monitor, exclude specific log lines, or highlight important patterns. Stern supports querying pods by Kubernetes resources like deployments or services using the format 'resource/name', making it easier to follow logs from entire application deployments.
Stern includes multiple output formats including JSON for programmatic use and custom Go templates for structured log processing. It integrates with standard Kubernetes authentication methods, respects namespace contexts, and provides color-coded output to distinguish between different pods and containers. The tool supports field selectors, label selectors, and various Kubernetes resource types including deployments, daemonsets, and statefulsets.
# via Homebrew
brew install stern
# via Go
go install github.com/stern/stern@latest
# via Kubectl Krew
kubectl krew install stern