kubectl plugin to parse and colorize JSON and timestamped logs, similar to jq but optimized for Kubernetes log streams.
- Works as both a kubectl plugin and k9s plugin (container scope)
- Parses Python
reprpayloads from OpenHands / agent-runner jobs (UUID, Enum, nested dicts)
- JSON Log Parsing: Pretty-prints JSON logs with colorized output (similar to
jq) - Python
reprParsing: Detects and formats OpenHands agentState:/Agent:blocks — handlesUUID(...),<Enum.VALUE: 'value'>, nested dicts/lists, and truncates long strings - Multi-line String Rendering: Displays multi-line values (e.g.
event, context summaries) as indented blocks instead of escaped\n - Pulumi Output Formatting: Automatically detects and pretty-prints Pulumi output in
msgfields with colorized resource status, outputs, and summaries - Timestamped Logs: Automatically detects and colorizes timestamps in non-JSON logs
- Log Level Detection: Colorizes log lines based on detected log levels (ERROR, WARN, INFO, DEBUG)
uv tool install git+https://github.com/rodrigoleven/kubectl-jsonlogsOr install from a local clone:
git clone https://github.com/rodrigoleven/kubectl-jsonlogs
uv tool install ./kubectl-jsonlogsVerify:
kubectl jsonlogs --helpTo update to the latest version:
uv tool upgrade kubectl-jsonlogsAdd the following to ~/Library/Application Support/k9s/plugins.yaml (macOS) or ~/.config/k9s/plugins.yaml (Linux):
plugins:
json-logs:
shortCut: Ctrl-J
confirm: false
description: "Pretty JSON Logs"
scopes:
- container
command: bash
background: false
args:
- -c
- "kubectl-jsonlogs $POD $NAMESPACE $CONTEXT $NAME 2>&1 | less -R"The plugin opens logs in less so you can scroll freely — press q to return to k9s.
Key points:
- The
containerscope means the shortcut is available from the k9s container view $NAMEis the container name; logs are fetched from that container only- Output is piped through
less -Rso ANSI colors are preserved and the view stays open until you pressq - Colors are always enabled in k9s mode (direct mode), regardless of TTY detection
To find your k9s config path:
k9s infokubectl logs <pod-name> | kubectl-jsonlogs
kubectl logs <pod-name> -c <container> | kubectl-jsonlogs# All containers
kubectl jsonlogs <pod-name> <namespace> <context>
# Specific container
kubectl jsonlogs <pod-name> <namespace> <context> <container-name>- Navigate to a pod's container view in k9s
- Press
Ctrl-J - Logs open in
lesswith full color — scroll with arrow keys orf/b, quit withq
| Element | Color |
|---|---|
| JSON keys | Blue |
| String values | Green |
| Numbers | Magenta |
| Booleans | Yellow |
| Brackets / braces | Cyan |
| Timestamps | Gray |
| ERROR level | Red |
| WARN level | Yellow |
| INFO level | Cyan |
| DEBUG level | Gray |
| UUID / Enum tokens | Magenta |
| Python dict keys | Blue |
Plugin not found by kubectl:
kubectl plugin list | grep jsonlogsIf missing, ensure ~/.local/bin is in your PATH:
export PATH="$HOME/.local/bin:$PATH"Black screen and back in k9s:
This happens when the plugin command exits immediately and k9s closes the overlay. Make sure your plugins.yaml uses the bash -c "... | less -R" form shown above — less keeps the output on screen until you press q.
No colors in k9s:
Ensure the plugin uses less -R (not plain less) so ANSI escape codes are rendered. The tool always emits colors in direct mode.
No colors in pipe mode:
Colors are disabled when stdout is not a TTY (e.g. redirected to a file). This is intentional for log aggregation compatibility.
Performance:
The script processes logs line-by-line for real-time streaming. For very high-volume logs consider using jq for pure JSON logs.
- Python 3.12+
uvfor installation
