stern extractJSONParts supports nested JSON fields with dot notation
Introduced 2026-10-22 · score 0.98
HOW TO USE IT
When formatting JSON log messages, use Stern’s template functions with dot notation to extract fields nested in JSON objects. For example, extract `python.levelname` from `.Message` with `extractJSONParts`.
stern --template='{{ extractJSONParts .Message "python.levelname" "message" }}{{"\n"}}' backendstern --template='{{ extractJSONParts .Message "python.levelname" }}{{"\n"}}' backendWHY THIS HELPS
When formatting JSON log messages, extract fields nested inside JSON objects.
BEFORE THIS CHANGE
For nested JSON fields, `extractJSONParts` and `tryExtractJSONParts` did only a flat top-level key lookup, so a dotted key rendered as `<nil>`.
REQUIREMENTS AND LIMITATIONS
- Version: v1.35.0
- --template: Custom Go template applied to each log message.
- .Message (required): String passed to the extraction function for JSON parsing.
- extractJSONParts (required): Parses the input string as JSON and concatenates the specified keys; keys may use dot notation to access nested fields.
- tryExtractJSONParts: Attempts JSON parsing and concatenates the specified keys using dot notation for nested fields; returns the text on failure.
- <pod-query> (required): Positional pod query; the documented example uses `backend`.
- A literal top-level key is tried first, preserving existing flat-key usage, including keys that already contain a dot.
FIRST-PARTY EVIDENCE
- https://github.com/stern/stern/releases/tag/v1.35.0
- https://github.com/stern/stern/pull/373
- https://github.com/stern/stern/blob/master/README.md
Check the installed version and the source before using it. Entry JSON