chmouel / snazy

a snazzy json log viewer (with one z)
Apache License 2.0
30 stars 2 forks source link
cli knative kubernetes logs rust tekton uber-zap

codecov Version AUR CICD pre-commit

snazy - a snazzy log viewer

Snazy is a simple tool to parse json or other type of logs and output them in a nice format with nice colors.

As a tekton and pipelines-as-code developer who has to dig into controller/webhook logs all the time I wanted something that is a bit easier to look in the eyes and identify error/info/warning statements easily.

You do not have to use it only with tekton but work well with projects that uses go-uber/zap library like knative and many others.

It can work as a super-"tail" too if you want to stream logs and being able to have "actions" or "highlights" on a regexp match.

Screenshot

screenshot

Installation

Binaries

Go to the release page and grab the archive or package targeting your platform.

Homebrew

brew tap chmouel/snazy https://github.com/chmouel/snazy
brew install snazy

Crates.io

cargo install snazy

Arch

With your favourite aurhelper for example yay :

yay -S snazy-bin

Nix/NixOS

Snazy is available from nixpkgs.

nix-env -iA snazy
nix run nixpkgs#snazy -- --help # your args are here

Bin

bin install github.com/chmouel/snazy 

Docker

kubectl logs deployment/pod foo|docker run -i ghcr.io/chmouel/snazy

Source install

Snazy is built with rust, if you want to compile it directly you just need to grab the source and run cargo build. (assuming you have the rust tool chain installed)

Usage

kubectl logs deployment/controller|snazy

screenshot

% kubectl log pod|snazy -r red:ERROR -r yellow:WARNING -r green:INFO -r 88,48,235:MITIGATED
% kubectl log pod|snazy -r fg=black,bg=yellow:ERROR
% kubectl log pod|snazy -f warning -f error

snazy level symbols

Interactive filtering with fzf

You can go even further with UNIX shell pipelines, and feed snazy to fzf for interactive filtering of the stream. for example to stream everything on a kubernetes cluster with kail, transforming the logs via snazy and finally using fzf to interactively select the patter to match:

kail --since=1h | snazy | fzf +s --ansi

This will give you a prompt with fzf where you can type the query you want.

Show GitHub Action Runs logs with snazy

An handy script located here let you show the log of a GitHub action runs through snazy and the bat pager.

You will need to setup the gh cli and install fzf to make it works.

Here is a video showing the feature https://streamable.com/7sf1hq

Shell completions

Shell completions are available for most shells using the command --shell-completion for example --shell-completion=zsh. Many different shell are supported. I let the reader figure out how to use them with their respective shells. Brew and RPM packages should have them auto configured for bash/fish/zsh.

FAQ

Copyright

Apache-2.0

Authors

Chmouel Boudjnah [@chmouel](https://twitter.com/chmouel)