From 5e05221a26d707b4af068d52ccbe5e60c4ae3dde Mon Sep 17 00:00:00 2001 From: Peter Denham Date: Tue, 11 Mar 2025 19:55:39 -0400 Subject: [PATCH] Feat: Add plugin support for parsing logs with bunyan cli #3153 (#3152) * Create log-bunyan.yaml * Update log-bunyan.yaml * Add bunyan to readme * Add install link for bunyan * fix plugin names * update available views --- plugins/README.md | 11 ++++++----- plugins/log-bunyan.yaml | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 plugins/log-bunyan.yaml diff --git a/plugins/README.md b/plugins/README.md index 86f957f3..29cd9ce9 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -12,12 +12,13 @@ Following is an example of some plugin files in this directory. Other files are | external-secrets.yaml | Refresh external/push-secrets | externalsecrets/pushsecrets | Shift-R | | | get-all.yaml | get all resources in a namespace | all | g | [Krew](https://krew.sigs.k8s.io/), [ketall](https://github.com/corneliusweig/ketall/) | | helm-diff.yaml | Diff with previous revision / current revision | helm/history | Shift-D/Q | [helm-diff](https://github.com/databus23/helm-diff) | -| job_suspend.yaml | Suspends a running cronjob | cronjobs | Ctrl-s | | -| k3d_root_shell.yaml | Root shell to k3d container | containers | Shift-s | [jq](https://stedolan.github.io/jq/) | +| job-suspend.yaml | Suspends a running cronjob | cronjobs | Ctrl-s | | +| k3d-root-shell.yaml | Root shell to k3d container | containers | Shift-s | [jq](https://stedolan.github.io/jq/) | | keda-toggle.yaml | Enable/disable [keda](3) ScaledObject autoscaler | scaledobjects | Ctrl-N | | -| log_stern.yaml | View resource logs using stern | pods | Ctrl-l | | -| log_jq.yaml | View resource logs using jq | pods | Ctrl-j | kubectl-plugins/kubectl-jq | -| log_full.yaml | get full logs from pod/container | pods/containers | Ctrl-l | | +| log-stern.yaml | View resource logs using stern | pods | Ctrl-l | | +| log-jq.yaml | View resource logs using jq | pods | Ctrl-j | kubectl-plugins/kubectl-jq | +| log-bunyan.yaml | View pods, service, deployment logs using bunyan | pods, service, deployment | Ctrl-l | [Bunyan](https://www.npmjs.com/package/bunyan) | +| log-full.yaml | get full logs from pod/container | pods/containers | Ctrl-l | | | resource-recommendations.yaml | View recommendations for CPU/Memory requests based on historical data | deployments/daemonsets/statefulsets | Shift-k | [Robusta KRR](https://github.com/robusta-dev/krr) | | trace-dns.yaml | Trace DNS resolution using Inspektor Gadget (4) | containers/pods/nodes | Shift-d | | | vector-dev-top.yaml | Run `vector top` in vector.dev container | pods/container | h | [vector top](https://vector.dev/highlights/2020-12-23-vector-top/) | diff --git a/plugins/log-bunyan.yaml b/plugins/log-bunyan.yaml new file mode 100644 index 00000000..443c4099 --- /dev/null +++ b/plugins/log-bunyan.yaml @@ -0,0 +1,42 @@ +# Forwards logs to bunyan cli for formatting +# Install Bunyan: https://www.npmjs.com/package/bunyan +plugins: + bunyanlogsp: + shortCut: Ctrl-L + confirm: false + description: "Logs (bunyan)" + scopes: + - pod + command: bash + background: false + args: + - -ic + - | + kubectl logs -f $NAME -n $NAMESPACE --context $CONTEXT | bunyan -o short + exit 0 + bunyanlogsd: + shortCut: Ctrl-L + confirm: false + description: "Logs (bunyan)" + scopes: + - deployment + command: bash + background: false + args: + - -ic + - | + kubectl logs -f deployment/$NAME -n $NAMESPACE --context $CONTEXT | bunyan -o short + exit 0 + bunyanlogss: + shortCut: Ctrl-L + confirm: false + description: "Logs (bunyan)" + scopes: + - service + command: bash + background: false + args: + - -ic + - | + kubectl logs -f service/$NAME -n $NAMESPACE --context $CONTEXT | bunyan -o short + exit 0