# stern

> Kubernetes log tailing tool that aggregates logs from multiple pods and containers with regex filtering and color coding

Stars: 4.9k · Language: Go · License: Apache-2.0 · Categories: System

- Repository: https://github.com/stern/stern
- Page: https://www.trmn.sh/tools/stern

## Install

- Homebrew: `brew install stern`
- Go: `go install github.com/stern/stern@latest`
- Kubectl Krew: `kubectl krew install stern`

## Overview

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.

### Installation

```bash
# via Homebrew
brew install stern
```

```bash
# via Go
go install github.com/stern/stern@latest
```

```bash
# via Kubectl Krew
kubectl krew install stern
```

## Alternatives

- [viddy](https://www.trmn.sh/tools/viddy.md): Enhanced watch command replacement with time machine mode, diff highlighting, and vim-like navigation (Go, 5.4k stars)
- [tufw](https://www.trmn.sh/tools/tufw.md): Terminal user interface for managing ufw firewall rules with add, edit, and remove functionality (Go, 875 stars)
- [kure](https://www.trmn.sh/tools/kure.md): Command-line password manager with AES-GCM encryption and offline operation (Go, 172 stars)
- [ssm](https://www.trmn.sh/tools/ssm.md): Terminal UI for managing and connecting to SSH hosts with vim-style navigation and tagging (Go, 114 stars)
- [Kopia](https://www.trmn.sh/tools/kopia.md): Cross-platform backup tool that creates encrypted, compressed, deduplicated snapshots and stores them on cloud, network, or local storage. Includes CLI and GUI. (Go, 14.6k stars)

## Guides

- [Modern Replacements for tail](https://www.trmn.sh/replace/tail): lnav and stern compared as tail replacements: local log files, journald and compressed logs with lnav, Kubernetes pod logs with stern.
- [Best Log Viewers for the Terminal](https://www.trmn.sh/best/log-viewers): Compare lnav, logss and stern for reading, tailing, searching and filtering logs in a terminal, from local files to Kubernetes pods.

---

Canonical: https://www.trmn.sh/tools/stern
