Releases: stern/stern
v1.33.1
v1.33.0
⚡ Notable Changes
New template variables Labels and Annotations
You can now use Labels and Annotations in your templates.
stern -n kube-system -l component --template '{{printf "%-25s %s" .Labels.component .Message}}{{"\n"}}'
Changes
v1.32.0
⚡ Notable Changes
A new template function prettyJSON
You can now use a new template function prettyJSON that parse input and emit it as pretty printed JSON. If it parse fails output string as is.
# Will try to parse .Message as JSON and pretty print it, if not json will output as is
stern --template='{{ .Message | prettyJSON }}{{"\n"}}' backend
# Or with parsed json, will drop non-json logs because of `with`
stern --template='{{ with $msg := .Message | tryParseJSON }}{{ prettyJSON $msg }}{{"\n"}}{{end}}' backend
A new template function bunyanLevelColor
You can now use a new template function bunyanLevelColor that print bunyan numeric log level using appropriate color.
A new flag --condition
A new --condition allows you to filter logs with the pod condition on: [condition-name[=condition-value]. The default condition-value is true. Match is case-insensitive. Currently, it is only supported with --tail=0 or --no-follow.
# Only display logs for pods that are not ready:
stern . --condition=ready=false --tail=0
Changes
- Add
--condition(#276) 2576972 (Felipe Santos) - Add check for when
--no-followis set with--tail=0(#331) 276e906 (Felipe Santos) - Implement JSON pretty print (#324) ccd8add (Fabio Napoleoni)
- Fix descriptions of
extjsonandppextjson(#325) d9a9858 (Takashi Kusumi) - Allow
levelColortemplate function to parse numbers (#321) db69276 (Jimmie Högklint)
v1.31.0
v1.30.0
⚡ Notable Changes
Add support for configuring colors for pods and containers
You can now configure highlight colors for pods and containers in the config file using a comma-separated list of SGR (Select Graphic Rendition) sequences. See the "Customize highlight colors" section for details.
Example configuration:
# Green, Yellow, Blue, Magenta, Cyan, White
pod-colors: "32,33,34,35,36,37"
# Colors with underline (4)
# If empty, the pod colors will be used as container colors
container-colors: "32;4,33;4,34;4,35;4,36;4,37;4"Display different colors for different containers
A new --diff-container flag allows displaying different colors for different containers. This is useful when you want to debug logs for multiple containers in the same pod.
You can also enable this feature in the config file.
diff-container: trueChanges
v1.29.0
⚡ Notable Changes
A new --stdin flag for parsing logs from stdin
A new --stdin flag has been added, allowing parsing logs from stdin. This flag is helpful when applying the same template to local logs.
stern --stdin --template \
'{{with $msg := .Message | tryParseJSON}}{{toTimestamp $msg.ts "01-02 15:04:05" "Asia/Tokyo"}} {{$msg.msg}}{{"\n"}}{{end}}' \
<etcd.log
Additionally, this feature helps test your template with arbitrary logs.
stern --stdin --template \
'{{with $msg := .Message | tryParseJSON}}{{levelColor $msg.level}} {{$msg.msg}}{{"\n"}}{{end}}' <<EOF
{"level":"info","msg":"info message"}
{"level":"error","msg":"error message"}
EOF
Add support for UNIX time with nanoseconds to template functions
The following template functions now support UNIX time seconds with nanoseconds (e.g., 1136171056.02).
toRFC3339NanotoTUCtoTimestamp
Changes
- Add support for UNIX time with nanoseconds to template functions (#300) 0d580ff (Takashi Kusumi)
- Clarify that '=' cannot be omitted in --timestamps (#296) ac36420 (Takashi Kusumi)
- Added example to README (#295) c1649ca (Thomas Güttler)
- Update dependencies for Kubernetes 1.30 (#293) d82cc9f (Kazuki Suda)
- Add
--stdinforstdinlog parsing (#292) 53fc746 (Jimmie Högklint)
v1.28.0
⚡ Notable Changes
Highlight matched strings in the log lines with the highlight option
Some part of a log line can be highlighted while still displaying all other logs lines.
--highlight flag now highlight matched strings in the log lines.
stern --highlight "\[error\]" .
v1.27.0
⚡ Notable Changes
Add new template function: toTimestamp
The toTimestamp function takes in an object, a layout, and optionally a timezone. This allows for more custom time parsing, for instance, if a user doesn't care about seeing the date of the log and only the time (in their own timezone) they can use a template such as:
--template '{{ with $msg := .Message | tryParseJSON }}[{{ toTimestamp $msg.time "15:04:05" "Local" }}] {{ $msg.msg }}{{ end }}{{ "\n" }}'
Add generic kubectl options
stern now has the generic options that kubectl has, and a new --show-hidden-options option.
$ stern --show-hidden-options
The following options can also be used in stern:
--as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace.
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string UID to impersonate for the operation.
--cache-dir string Default cache directory (default "/home/ksuda/.kube/cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--disable-compression If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
--server string The address and port of the Kubernetes API server
--tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
The number of kubectl generic options is so large that it makes it difficult to see stern's own list of options, so we usually hide them. Use --show-hidden-options if you want to list.
v1.26.0
⚡ Notable Changes
Add new template functions
The following template functions have been added in v1.26.0:
extractJSONParts: Parse string as JSON and concatenate the given keystryExtractJSONParts: Attempt to parse string as JSON and concatenate the given keys, returning text on failure
Changes
- Fix the release workflow (#275) 91d4cd6 (Kazuki Suda)
- Update dependencies and tools (#273) cb94677 (Takashi Kusumi)
- Possibility to extract parts of a json-message. (#271) d49142c (Niels)
- Fix potential panic in stern.Run() (#267) dcba2dd (Takashi Kusumi)
- Add log level color keys and handle default (#264) 65204cc (Jimmie Högklint)
- Fix typo in README.md (#261) d7d5a4f (Will May)
- Integrate fmt and vet checks into golangci-lint (#260) 1d242bc (Takashi Kusumi)
- Update Github Actions dependencies (#259) 9e833da (Takashi Kusumi)
v1.25.0
⚡ Notable Changes
Add support for the config file
You can now 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: shortYou can change the config file path with --config flag or STERNCONFIG environment variable.
Changes
- Fix the heading level in README.md (#257) c2290b4 (Kazuki Suda)
- Update dependencies and tools (#256) 531f869 (Kazuki Suda)
- Allow an empty config file (#255) c76ea87 (Takashi Kusumi)
- Add support for the config file (#254) 2fdc298 (Kazuki Suda)
- Make setup-go get Go version from go.mod (#253) 23feff7 (Takashi Kusumi)