stern is a free, open source monitoring & observability project written in Go and released under Apache-2.0. It has 4,862 GitHub stars, 178 forks and 39 open issues, and was last pushed 4 days ago. On this registry it ranks #72 of 97 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

What is stern?

Stern is a command-line tool that tails logs from multiple Kubernetes pods and multiple containers at the same time, colour-coding each result, and it is built for developers and operators who debug workloads on Kubernetes instead of reading pods one at a time.

What it is

Stern is a log tailing utility for Kubernetes, written in Go and released under the Apache-2.0 licence. It is a fork of the discontinued wercker/stern, and it lives in the Kubernetes tooling ecosystem as a companion to kubectl rather than a replacement for the cluster itself. The current repository, stern/stern, carries 4863 stars, 178 forks and 39 open issues, and its topics describe the intended ground clearly: debugging, devops, kubernetes, logging, logs and tail.

The concrete thing it replaces is the manual loop of running kubectl logs -f against one pod at a time and repeating that per container. Stern takes a single pod-query instead. That query is either a regular expression, so "web-\w" matches web-backend and web-frontend but not web-123, or a Kubernetes resource in the form resource/name, such as deployment/nginx, which selects every pod belonging to that resource by exact match. Supported resources are pod, replicationcontroller, service, daemonset, deployment, replicaset, statefulset and job.

Key capabilities

  • Tails multiple pods and, inside each pod, multiple containers without repeating the command per container; --container, -c limits the set and --exclude-container, -E removes names, both as regular expressions.
  • Follows pod lifecycle automatically: a deleted pod drops out of the tail and a newly added pod is tailed without restarting the command.
  • Runs the query as stern pod-query [flags], with colour output controlled by --color (auto, always, never) and per-container colour differentiation via --diff-container, -d, plus --pod-colors and --container-colors.
  • Filters noise with --exclude, -e for log lines and --condition for condition-name matching, where the default condition value is true and matching is case-insensitive.
  • Selects container state through --container-state (running, waiting, terminated, or all), and includes or excludes ephemeral containers through --ephemeral-containers.
  • Spans namespaces with --all-namespaces, -A, and selects cluster context with --context; API throttling is tunable with --burst and --qps.
  • Reads defaults from a config file at ~/.config/stern/config.yaml via --config, and emits shell completion for bash, zsh or fish through --completion.

Who uses it and how

  • Developers debugging a deployment interactively, filtering by resource form such as deployment/nginx so the exact pod id, including the deployment suffix, does not need to be known.
  • Operators watching a whole namespace, or every namespace with -A, during an incident when the failing workload is not yet identified.
  • Teams working in clusters that run multi-container pods, where --container narrows the stream and --exclude-container removes sidecars.
  • kubectl plugin users, who install stern through Krew as kubectl krew install stern and keep it alongside their existing CLI workflow.
  • Windows users, who install through WinGet as winget install stern.stern, a path the README calls the usual best option on that platform.

Getting started

Install from a binary release, or use go install github.com/stern/stern@latest, brew install stern, asdf plugin add stern followed by asdf install stern latest, kubectl krew install stern, or winget install stern.stern. Then run stern pod-query [flags] against a kubeconfig context.

How it compares

Among tools named in the facts, the reference point is wercker/stern, which the README marks as discontinued; stern/stern is the friendly fork that continues that codebase, so existing wercker/stern users are the natural audience for a switch. Beyond that lineage, the facts name no other comparable tailing tool, and the project stands on its own in this registry.

When to use it — and when not to

Stern is a single client binary, so there is no server, database or SMTP service to operate; the requirement is a kubeconfig, a context and API access to the cluster being tailed. It is the wrong choice when the goal is log storage, retention or search, since it tails live output and does not persist anything, and it is useless outside Kubernetes. One limitation worth noting from the README: --condition filtering is currently supported only with --tail=0 or --no-follow, so condition-based selection cannot be combined with a live follow.

project readme (upstream, from github) — read inline

Build

stern

Fork of discontinued wercker/stern

Stern allows you to tail multiple pods on Kubernetes and multiple containers within the pod. Each result is color coded for quicker debugging.

The query is a regular expression or a Kubernetes resource in the form / so the pod name can easily be filtered and you don't need to specify the exact id (for instance omitting the deployment id). If a pod is deleted it gets removed from tail and if a new pod is added it automatically gets tailed.

When a pod contains multiple containers Stern can tail all of them too without having to do this manually for each one. Simply specify the container flag to limit what containers to show. By default all containers are listened to.

Installation

Download binary

Download a binary release

Build from source

go install github.com/stern/stern@latest

asdf (Linux/macOS)

If you use asdf, you can install like this:

asdf plugin add stern
asdf install stern latest

Homebrew (Linux/macOS)

If you use Homebrew, you can install like this:

brew install stern

Krew (Linux/macOS/Windows)

If you use Krew which is the package manager for kubectl plugins, you can install like this:

kubectl krew install stern

WinGet (Windows)

If you're running on Windows, usually the actual best way is to use WinGet to install which is Windows' built-in package manager, you can install like this:

winget install stern.stern

Usage

stern pod-query [flags]

The pod-query is a regular expression or a Kubernetes resource in the form /.

The query is a regular expression when it is not a Kubernetes resource, so you could provide "web-\w" to tail web-backend and web-frontend pods but not web-123.

When the query is in the form / (exact match), you can select all pods belonging to the specified Kubernetes resource, such as deployment/nginx. Supported Kubernetes resources are pod, replicationcontroller, service, daemonset, deployment, replicaset, statefulset and job.

cli flags

flag default purpose
--all-namespaces, -A false If present, tail across all namespaces. A specific namespace is ignored even if specified with --namespace.
--burst 0 Maximum burst for throttle to the Kubernetes API server. Defaults to 0 (use client-go default). Ignored when --qps=-1.
--color auto Force set color output. 'auto': colorize if tty attached, 'always': always colorize, 'never': never colorize.
--completion Output stern command-line completion code for the specified shell. Can be 'bash', 'zsh' or 'fish'.
--condition The condition to filter on: [condition-name[=condition-value]. The default condition-value is true. Match is case-insensitive. Currently only supported with --tail=0 or --no-follow.
--config ~/.config/stern/config.yaml Path to the stern config file
--container, -c .* Container name when multiple containers in pod. (regular expression)
--container-colors Specifies the colors used to highlight container names. Use the same format as --pod-colors. Defaults to the values of --pod-colors if omitted, and must match its length.
--container-state all Tail containers with state in running, waiting, terminated, or all. 'all' matches all container states. To specify multiple states, repeat this or set comma-separated value.
--context The name of the kubeconfig context to use
--diff-container, -d false Display different colors for different containers.
--ephemeral-containers true Include or exclude ephemeral containers.
--exclude, -e [] Log lines to exclude. (regular expression)
--exclude-container, -E [] Container name to exclude when multiple containers in pod. (regular expression)
--exclude-pod [] Pod name to exclude. (regular expression)
--field-selector Selector (field query) to filter on. If present, default to ".*" for the pod-query.
--highlight, -H [] Log lines to highlight. (regular expression)
--include, -i [] Log lines to include. (regular expression)
--init-containers true Include or exclude init containers.
--kubeconfig Path to the kubeconfig file to use for CLI requests.
--max-log-requests -1 Maximum number of concurrent logs to request. Defaults to 50, but 5 when specifying --no-follow
--namespace, -n Kubernetes namespace to use. Default to namespace configured in kubernetes context. To specify multiple namespaces, repeat this or set comma-separated value.
--no-follow false Exit when all logs have been shown.
--node Node name to filter on.
--only-log-lines false Print only log lines
--output, -o default Specify predefined template. Currently support: [default, raw, json, extjson, ppextjson]
--pod-colors Specifies the colors used to highlight pod names. Provide colors as a comma-separated list using SGR (Select Graphic Rendition) sequences, e.g., "91,92,93,94,95,96".
--prompt, -p false Toggle interactive prompt for selecting 'app.kubernetes.io/instance' label values.
--qps 0 Maximum QPS to the Kubernetes API server. Defaults to 0 (use client-go default). Use -1 to disable client-side throttling.
--selector, -l Selector (label query) to filter on. If present, default to ".*" for the pod-query.
--show-hidden-options false Print a list of hidden options.
--since, -s 48h0m0s Return logs newer than a relative duration like 5s, 2m, or 3h.
--stdin false Parse logs from stdin. All Kubernetes related flags are ignored when it is set.
--tail -1 The number of lines from the end of the logs to show. Defaults to -1, showing all logs.
--template Template to use for log lines, leave empty to use --output flag.
--template-file, -T Path to template to use for log lines, leave empty to use --output flag. It overrides --template option.
--timestamps, -t Print timestamps with the specified format. One of 'default' or 'short' in the form '--timestamps=format' ('=' cannot be omitted). If specified but without value, 'default' is used.
--timezone Local Set timestamps to specific timezone.
--verbosity 0 Number of the log level verbosity
--version, -v false Print the version and exit.

See stern --help for details

Stern will use the $KUBECONFIG environment variable if set. If both the environment variable and --kubeconfig flag are passed the cli flag will be used.

config file

You can use the config file to change the default values of stern options. The default config file path is ~/.config/stern/config.yaml.

# <flag name>: <value>
tail: 10
max-log-requests: 999
timestamps: short

You can change the config file path with --config flag or STERNCONFIG environment variable.

templates

stern supports outputting custom

readme truncated — read the full docs on github

Frequently asked questions

Is stern free to use?

stern is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does stern do?

⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern

What is stern written in?

stern is primarily written in Go. Its source is publicly available at https://github.com/stern/stern, and it has 4,862 GitHub stars.