Crates.io | woodchipper |
lib.rs | woodchipper |
version | 1.1.0 |
source | src |
created_at | 2019-06-12 19:37:55.127856 |
updated_at | 2019-10-28 23:21:12.147628 |
description | An interactive command-line log processor |
homepage | https://github.com/HewlettPackard/woodchipper/ |
repository | https://github.com/HewlettPackard/woodchipper/ |
max_upload_size | |
id | 140660 |
size | 208,152 |
Follow, transform, and explore all your unwieldly microservice logs from the terminal.
Grab a pre-built binary from the releases page or run:
cargo install woodchipper
See the install page for detailed instructions.
Follow some logs:
tail -f /var/log/my-app.log | woodchipper
Use the kubectl
plugin wrapper script and watch some pods:
kubectl woodchipper -n my-namespace app=my-app
Pipe any logs to woodchipper
:
cat my-log.txt | woodchipper
This opens the interactive viewer by default. Use up, down, page up, page down, home, and end to navigate.
woodchipper also follows any streaming output:
./some-long-running-script.sh | woodchipper
When piped, woodchipper automatically outputs nicely formatted plaintext, appropriate for sharing:
./some-hard-to-read-json-logs.sh | woodchipper | cat
Alternatively, if you'd just like to print the colorized logs to your terminal:
./logs.sh | woodchipper -r styled
If you don't like the interactive viewer but still want a pager, try less
:
cat logs.txt | woodchipper -r styled | less
(try less -R
if your less
doesn't pass through ANSI escapes by default)
The interactive viewer provides an improved pager with regex searching and filtering. It's enabled by default if woodchipper is attached to a tty.
A number of keyboard shortcuts are available:
up
, down
: move the cursor one message at a timepage up
, page down
: scroll one screenful at a timehome
, end
: move to the start or end of all messagesf
, |
: add a filter to the stack
enter
: add the filter to the stack and remove all non-matching messagesesc
: cancel filterp
: pop the last filter from the stack/
, ctrl-f
: search for a particular message; when in filter mode:
enter
: next matchctrl-p
: previous matchesc
: end search; if a result is highlighted, it will remain highlightedc
: copy the selected message to the clipboard as shareable plain textshift-c
: copy the current screen to the clipboard as shareable plain textq
: quitThe interactive viewer works best with terminal emulators that treat mouse wheel input as up / down keypresses when in alternate screen mode. KDE's Konsole behaves this way by default, and this may be enabled in iTerm2 in Preferences -> Advanced -> Mouse -> "Scroll wheel sends arrow keys when in alternative screen mode". An option to capture mouse events on all terminals may be added in the future, however doing so disables text selection and isn't ideal.
For
kubectl
1.13+, read more
To make full use of the Kubernetes integration:
kubectl
is available and configured on your $PATH
$PATH
Woodchipper uses kubectl proxy
to access the Kubernetes API, so it can
connect to your cluster if kubectl
can.
To follow a pod named my-pod-1234
, run:
kubectl woodchipper -n my-namespace my-pod-1234
Alternatively, if you don't want to use the kubectl plugin, this is equivalent:
woodchipper --reader=kubernetes -n my-namespace my-pod-1234
Woodchipper matches pods continually using substrings, so a partial pod name will follow pods even between restarts or deployment upgrades:
woodchipper --reader=kubernetes -n my-namespace my-pod
Multiple substrings can be used:
kubectl woodchipper -n my-namespace my-pod my-other-pod
Alternatively, if you give it a label-like selector, it will perform a label query:
kubectl woodchipper -n my-namespace app=my-app
Note that only one label selector may be used at a time.
Woodchipper honors your configured kubectl
default namespace, so you can
leave off -n my-namespace
if kubectl
is configured to use it already.
Alternatively, the WD_NAMESPACE
environment variable can be set to override
the default.
Woodchipper can parse, format, and stylize any of the following logs, potentially mixed together:
{"time": "...", "msg": "hello world"}
time="..." msg="hello world"
Bug reports, feature requests, and pull requests are welcome! Be sure to read though the code of conduct for some pointers to get started.
Note that - as mentioned in the code of conduct - code contributions must
indicate that you accept the Developer Certificate of Origin,
essentially indicating you have rights to the code you're contributing and
that you agree to the project's license (MIT). With the Git CLI, simply pass
-s
to git commit
:
git commit -s [...]
... and Git will automatically append the required Signed-off-by: ...
to the
end of your commit message.
Additionally, the design documentation may be a helpful resource for understanding how woodchipper works.