Stern: a multi-pod log tailer for Kubernetes
⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern
At a glance
- What is it?
- Stern tails logs from many Kubernetes pods and containers at once, color coding each stream so operators can debug distributed workloads without naming every pod by id.
- Who is it for?
- Stern is a focused utility that turns the noisy task of reading Kubernetes logs into a single color coded stream across many pods and containers. It accepts either a regular expression or a resource reference as its query, follows pods as they are created or deleted, and exposes fine grained control over namespaces, containers, filtering, output format, and timestamps.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 17 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Stern is a multi-pod log tailer for Kubernetes
Stern allows you to tail multiple pods on Kubernetes and multiple containers within the pod. Each result is color coded for quicker debugging. It is a fork of the discontinued wercker/stern project, carrying the tool forward after the original was no longer maintained. The query is a regular expression or a Kubernetes resource in the form `<resource>/<name>`, so the pod name can be filtered without specifying the exact id, such as omitting the deployment id. If a pod is deleted it gets removed from the tail, and if a new pod is added it is automatically tailed. This behavior suits dynamic workloads where replicas come and go, because the operator does not have to restart the tailing session by hand.
Installing Stern across package managers
Several installation paths are documented. You can download a binary release, build from source, or use a package manager already present on your system. Building from source uses the Go toolchain with a single install command. On Linux and macOS, asdf, Homebrew, and Krew are supported; on Windows, WinGet is the recommended route. Krew installs stern as a kubectl plugin, which keeps it alongside other kubectl extensions. Because the tool ships through many channels, most operators can install it with the manager they already use rather than adding a new one just for logs.
go install github.com/stern/stern@latestkubectl krew install sternHow the pod query selects what to tail
The basic invocation is `stern pod-query [flags]`. The pod-query is a regular expression or a Kubernetes resource such as `<resource>/<name>`. When it is a regular expression, you can target related pods at once; for example `"web-\w"` tails `web-backend` and `web-frontend` but not `web-123`. When the query is a resource reference like `deployment/nginx`, stern selects all pods belonging to that resource. Supported resource kinds are pod, replicationcontroller, service, daemonset, deployment, replicaset, statefulset and job. This dual mode means the same command works whether you think in terms of a name pattern or in terms of a higher level object such as a deployment.
stern pod-query [flags]Tailing multiple containers in a single pod
When a pod runs more than one container, stern can tail all of them without manual setup for each. The `--container` flag, short form `-c`, limits which containers are shown, and by default it listens to all containers using a regular expression. You can also exclude specific containers with `--exclude-container` and exclude whole pods with `--exclude-pod`. The `--diff-container` flag displays different colors for different containers so the output stays readable when many streams are merged into one view. For sidecar heavy pods, this keeps the application log separate from proxy or helper logs by color alone.
Filtering, highlighting, and color output
Stern offers several flags for shaping the stream. `-A` or `--all-namespaces` tails across every namespace, while `-n` or `--namespace` restricts to one. `--include` and `--exclude` accept regular expressions to filter log lines, and `--highlight` marks matching lines. Color output is controlled by `--color` with the values `auto`, `always`, or `never`, so it can be forced on for saved output or forced off for plain text. `--pod-colors` and `--container-colors` accept comma-separated SGR sequences so teams can tune the palette, and `--only-log-lines` prints just the message text without the pod and container prefix.
Output formats and custom templates
The `--output` flag selects a predefined template: `default`, `raw`, `json`, `extjson`, or `ppextjson`. `raw` is useful when logs are JSON and you want to pipe them to `jq`, while the JSON variants help with programmatic processing and downstream tooling. A custom Go template can be passed with `--template` or loaded from a file with `--template-file`. The template receives the log message, timestamp, node name, namespace, pod name, container name, labels, and annotations, and helper functions such as `parseJSON`, `prettyJSON`, and `levelColor` are available. That design lets a team reshape the stream for a specific dashboard without leaving stern.
Streaming control, timestamps, and verbosity
`--no-follow` exits once all logs have been shown, and `--tail` sets how many lines from the end to display. `--since` returns logs newer than a relative duration such as `5s`, `2m`, or `3h`, and `--timestamps` prints timestamps with a chosen format plus `--timezone`. The `--max-log-requests` flag caps concurrent log requests so a large cluster is not overloaded; its default differs depending on whether `--no-follow` is set. `--verbosity` raises the log level to show how stern talks to the Kubernetes API server, which helps when troubleshooting connection or permission problems against a busy control plane.
Running Stern in containers and clusters
Stern can run as a container image with `docker run ghcr.io/stern/stern --version`, and on minikube it mounts the local kube and minikube config. To run stern inside a Kubernetes pod, you create a ClusterRole granting `get`, `watch`, and `list` on `pods` and `pods/log`, then bind it to a ServiceAccount. Shell completion is available for bash, zsh, and fish via `stern --completion`. A config file at `~/.config/stern/config.yaml` changes default flag values and can be overridden with `--config` or the `STERNCONFIG` variable, which lets a team standardize options across every session.
Editorial conclusion
Stern is a focused utility that turns the noisy task of reading Kubernetes logs into a single color coded stream across many pods and containers. It accepts either a regular expression or a resource reference as its query, follows pods as they are created or deleted, and exposes fine grained control over namespaces, containers, filtering, output format, and timestamps. With installs through Go, asdf, Homebrew, Krew, and WinGet, plus container and in cluster modes, it fits most environments where operators already work. For debugging distributed services, the combination of multi pod tailing and templated output makes stern a practical everyday companion to kubectl.
Frequently asked questions
What problem does stern solve for Kubernetes operators?
Stern lets you tail logs from multiple pods and multiple containers in one color coded stream, so you can watch a distributed workload without naming every pod by its exact id. The README states that deleted pods leave the tail and new pods are tailed automatically.
Can stern follow logs from pods that start after it begins?
Yes. The README says that if a new pod is added it gets tailed automatically, and if a pod is deleted it is removed from the tail. This makes stern suited to workloads whose replicas scale up and down.
Does stern require specifying an exact pod id to tail it?
No. The query is a regular expression or a Kubernetes resource such as deployment/nginx, and the README notes you do not need to specify the exact id, for instance omitting the deployment id when filtering pod names.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/stern-stern)