# nginx — access-log dashboard from JSON access logs
# tail -f access.json | arb -p nginx
bars .status
source .status { in.json; field status; tally }
bars .top_requests -top 10
source .top_requests { in.json; field request; tally }
tail .requests
source .requests { in.json; field request }
test "status tally" {
given "{\"status\":200,\"request\":\"GET /\"}" "{\"status\":200,\"request\":\"GET /a\"}" "{\"status\":404,\"request\":\"GET /missing\"}"
run { in.json; field status; tally }
want "200\t2" "404\t1"
}
test "top requests by count" {
# tally sorts by count desc, then key asc — the bars widget caps via -top 10.
given "{\"request\":\"GET /a\"}" "{\"request\":\"GET /b\"}" "{\"request\":\"GET /a\"}" "{\"request\":\"GET /c\"}" "{\"request\":\"GET /a\"}" "{\"request\":\"GET /b\"}"
run { in.json; field request; tally }
want "GET /a\t3" "GET /b\t2" "GET /c\t1"
}