arblang 0.1.24

Visualize and modify Unix pipelines: pipe a stream in, arb spawns a dynamic TUI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
# journalctl — syslog priority levels, top units, and error count
#   journalctl -o json -f | arb -p journalctl
bars .priority
source .priority { in.json; field PRIORITY; tally }
bars .units
source .units { in.json; field _SYSTEMD_UNIT; tally }
gauge .errors -max 500
source .errors { in.json; where PRIORITY < 4; count }

test "priority tally" { given "{\"PRIORITY\":\"6\",\"_SYSTEMD_UNIT\":\"sshd.service\"}" "{\"PRIORITY\":\"3\",\"_SYSTEMD_UNIT\":\"nginx.service\"}" "{\"PRIORITY\":\"6\",\"_SYSTEMD_UNIT\":\"sshd.service\"}"; run { in.json; field PRIORITY; tally }; want "6\t2" "3\t1" }
test "unit tally" { given "{\"PRIORITY\":\"6\",\"_SYSTEMD_UNIT\":\"sshd.service\"}" "{\"PRIORITY\":\"3\",\"_SYSTEMD_UNIT\":\"nginx.service\"}" "{\"PRIORITY\":\"6\",\"_SYSTEMD_UNIT\":\"sshd.service\"}"; run { in.json; field _SYSTEMD_UNIT; tally }; want "sshd.service\t2" "nginx.service\t1" }
test "error count" { given "{\"PRIORITY\":\"6\",\"_SYSTEMD_UNIT\":\"sshd.service\"}" "{\"PRIORITY\":\"3\",\"_SYSTEMD_UNIT\":\"nginx.service\"}" "{\"PRIORITY\":\"2\",\"_SYSTEMD_UNIT\":\"kernel\"}"; run { in.json; where PRIORITY < 4; count }; want "2" }