Stern
$ stern Community Low RiskStern (stern) tails logs across multiple Kubernetes pods and containers simultaneously using regex pod matching, label selectors (-l), and namespaces (-n). Passing -o json (or -o raw), --no-follow, and --since enables bounded, machine-parseable log retrieval for agents.
brew install stern stern aggregates multi-pod logs with regex, --since, --tail, and -o json in one command—much cleaner than multi-call kubectl or MCP log loops.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports -o json, --color never, --no-follow, --since, and --tail, though forgetting --no-follow leaves the process streaming forever.
- Supports
-o json,-o raw,--color never, and--no-follow - Follows logs indefinitely unless
--no-followis specified
Strictly read-only log viewer with namespace (-n) and context (--context) scoping, though application logs may contain sensitive runtime data.
- Read-only Kubernetes Pod/log API access only
Single static Go binary available via Homebrew, Krew, go install, and GitHub releases on macOS, Linux, and Windows.
- Zero-dependency Go binary via
brew install stern
Dramatically reduces boilerplate when gathering logs from multi-replica Deployments compared to kubectl logs.
- Regex pod matching + label selectors + Go template parsing (
--template)
Community-maintained continuation (stern/stern) under Apache-2.0 license.
- Active
stern/sternrepository under Apache-2.0
Clear README flag tables and --help output.
- Documented in GitHub README and
stern --help
Security, Auth & Guardrails
Reads standard kubeconfig (~/.kube/config, KUBECONFIG, --context) for read-only Pod log streaming.
Apache-2.0 open-source CLI; free read-only cluster log utility.
# Stern Agent Rules - ALWAYS pass `--no-follow` alongside `--since` or `--tail` so `stern` exits instead of streaming indefinitely. - Pass `-o json` and `--color never` when parsing pod logs programmatically.
Agent-Ready Command Recipes
Safe Read-Only Queries
stern "api-.*" -n prod --since 10m --tail 50 --no-follow -o json --color never
Grabs the last 50 log lines within 10 minutes as JSON objects and exits immediately.
stern . -l app=worker --since 5m --no-follow -o raw
Collects raw log messages from pods matching app=worker.
Strengths for Agents
- +
-o json --no-follow --since 10m --tail 50returns clean, bounded JSON log records. - + 100% read-only across multi-replica pods and multi-container workloads.
- + Built-in
--templateJSON parsing helpers (parseJSON,tryParseJSON).
Caveats & Pitfalls
- ! Streams continuously by default—omitting
--no-followwill hang agent command calls until timeout. - ! Large
--tailor unbounded regex matches can flood context windows quickly.