LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kubetail

tails logs from multiple pods simultaneously

TLDR

Tail pods matching a name pattern
$ kubetail [pod-name-prefix]
copy
Tail pods by label selector
$ kubetail -l [app=myapp]
copy
Tail in a specific namespace
$ kubetail [pattern] -n [namespace]
copy
Tail a specific container (repeatable)
$ kubetail [pattern] -c [container]
copy
Show only the last N minutes of logs
$ kubetail [pattern] -s [10m]
copy
Show timestamps
$ kubetail [pattern] --timestamps
copy
Tail with regex matching
$ kubetail "[^app1|.*demo.*]" --regex
copy
Dry-run: list matching pods without tailing
$ kubetail [pattern] -d
copy

SYNOPSIS

kubetail [pod-pattern] [options]

DESCRIPTION

kubetail is a Bash script that aggregates and tails log output from multiple Kubernetes pods simultaneously. It matches pods by name prefix, regex, or label selector and streams their logs in a single terminal, using color-coded output to distinguish lines from different pods.The tool is useful when debugging distributed applications or microservices where related log entries are spread across several pod replicas. Under the hood, kubetail spawns multiple `kubectl logs --follow` processes and merges their output, optionally filtering by namespace, container, or duration.Defaults for most flags can be set via environment variables such as KUBETAILNAMESPACE, KUBETAILSINCE, KUBETAILTAIL, and KUBETAILCOLORED_OUTPUT.

PARAMETERS

PATTERN

Pod name pattern (prefix match by default, regex with --regex).
-c, --container NAME
Container name (repeatable for multiple containers).
-t, --context CONTEXT
Kubernetes context to use.
-l, --selector SELECTOR
Label selector (e.g., app=myapp).
-n, --namespace NAMESPACE
Target namespace.
-e, --regex MODE
Match mode: regex or substring.
-s, --since DURATION
Show logs since relative duration (e.g., 10m, 1h).
-p, --previous BOOL
Retrieve logs from previous pod instances.
-f, --follow BOOL
Follow log stream (default true).
-d, --dry-run
Print matching pods/containers without tailing.
-k, --colored-output MODE
Coloring mode: pod, line (default), loglevel, or false.
-z, --skip-colors LIST
Comma-separated color indices to skip.
-P, --prefix BOOL
Toggle pod name prefix on each line.
-b, --line-buffered BOOL
Control line buffering.
-j, --jq SELECTOR
Apply jq selector to JSON log lines.
-r, --cluster NAME
Kubeconfig cluster name.
--tail LINES
Limit number of recent lines per pod.
--timestamps
Display timestamps on log lines.
-i, --show-color-index BOOL
Display color index with pod prefix.
-v, --version
Show version.
-h, --help
Display help information.

CAVEATS

Third-party Bash script (not part of kubectl). Requires `kubectl` configured with cluster access. For Go-based alternatives with similar functionality, see stern.

HISTORY

kubetail was created by Johan Haleby to simplify tailing logs from multiple Kubernetes pods with a single command.

SEE ALSO

kubectl(1), stern(1), k9s(1)

Copied to clipboard
Kai