A simple line-text formatter that makes it simple to parse, filter, and format live logs turning noise into meaningful insights.
An example of Grits in action: the left pane shows Grits being applied, and the right pane displays the raw logs.
At its core, grits
applies regular expressions with named captures to input lines. These captures are then available as variables
(a.k.a. anchors) which can then be used in a grits
template string. The template string supports text-alignment, colorization,
as well as other attributes you'd expect using ANSI escape sequences.
The following example demonstrates how to apply grits
to tcpdump
to extract an output line's timestamp (ts
) and
a packet's source (src
) and destination (dst
) IP address:
tcpdump -nn | grits -- \
-p '^(?<ts>[^ ]+)' \
-p 'IP\w? (?<src>[^ ]+)' \
-p '> (?<dst>[^ ]+):' \
-t '[{(cyan|bold):ts}] {(green|underlined):"src"}={(lalign(45)):src} {(yellow|underlined):"dst"}={dst}'
The top pane in the above screenshot is the raw output of tcpdump while the bottom pane shows the output being piped into grits.
cargo install grits
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/solidiquis/grits/releases/download/v0.3.0/grits-installer.sh | sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/solidiquis/grits/releases/download/v0.3.0/grits-installer.ps1 | iex"
Check the releases page for prebuilt binaries.
The documentation for grits
can be found here. It is also available in the CLI via --help
.
All well-intentioned forms of contributions are welcome.
If you like this tool, please consider buying me a coffee. Much appreciated!
-
Q: Have you heard of lnav? Why should I use grits over lnav?
-
A: I have heard of lnav but I haven't used it. Users are encouraged to use both to see what best fits their needs.
-
Q: Why is this called grits?
-
A: I was really craving shrimp & grits while writing this on a plane going to South Korea. Also, checkout my Spotify playlist called Melancholy with a side of Grits.