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
13
14
# haproxy — JSON access log: status codes, backend latency, live requests
#   tail -f /var/log/haproxy.json | arb -p haproxy
bars .status
source .status { in.json; field status; tally }
bars .backend
source .backend { in.json; field backend_name; tally }
gauge .slow -max 50
source .slow { in.json; where Tt > 1000; count }
tail .log
source .log { in.json; field http_request }

test "status tally" { given "{\"status\":200,\"Tt\":1500,\"backend_name\":\"web\"}" "{\"status\":500,\"Tt\":800,\"backend_name\":\"api\"}" "{\"status\":200,\"Tt\":2000,\"backend_name\":\"web\"}"; run { in.json; field status; tally }; want "200\t2" "500\t1" }
test "backend tally" { given "{\"status\":200,\"Tt\":1500,\"backend_name\":\"web\"}" "{\"status\":500,\"Tt\":800,\"backend_name\":\"api\"}" "{\"status\":200,\"Tt\":2000,\"backend_name\":\"web\"}"; run { in.json; field backend_name; tally }; want "web\t2" "api\t1" }
test "slow count" { given "{\"status\":200,\"Tt\":1500}" "{\"status\":500,\"Tt\":800}" "{\"status\":200,\"Tt\":2000}"; run { in.json; where Tt > 1000; count }; want "2" }