Last active
November 14, 2024 10:35
-
-
Save ammarnajjar/8203e242a5f1d772d1a0beb104225e27 to your computer and use it in GitHub Desktop.
k9s plugin to pretty print json logs using jq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $XDG_CONFIG_HOME/k9s/plugins.yaml | |
plugins: | |
jqlogs: | |
shortCut: Ctrl-J | |
confirm: false | |
description: "Logs (jq)" | |
scopes: | |
- pod | |
command: sh | |
background: false | |
args: | |
- -c | |
- "kubectl logs -f $NAME -n $NAMESPACE --context $CONTEXT |jq -SR '. as $line | try (fromjson) catch $line'" | |
jqlogsd: | |
shortCut: Ctrl-J | |
confirm: false | |
description: "Logs (jq)" | |
scopes: | |
- deployment | |
command: sh | |
background: false | |
args: | |
- -c | |
- "kubectl logs -f deployment/$NAME -n $NAMESPACE --context $CONTEXT |jq -SR '. as $line | try (fromjson) catch $line'" | |
jqlogss: | |
shortCut: Ctrl-J | |
confirm: false | |
description: "Logs (jq)" | |
scopes: | |
- service | |
command: sh | |
background: false | |
args: | |
- -c | |
- "kubectl logs -f service/$NAME -n $NAMESPACE --context $CONTEXT |jq -SR '. as $line | try (fromjson) catch $line'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work for pods with multiple containers, but with added scope it does: