# apache — access-log status codes, top client IPs, request volume, and live requests
# tail -f access.log | arb -p apache
bars .status
source .status { in; field 9; tally }
bars .ips
source .ips { in; field 1; tally }
gauge .hits -max 10000
source .hits { in; count }
tail .log
source .log { in }
test "status tally by response code" { given "1.1.1.1 - - [10/Oct/2000:13:55:36 -0700] \"GET / HTTP/1.1\" 200 12" "1.1.1.2 - - [10/Oct/2000:13:55:37 -0700] \"GET /a HTTP/1.1\" 404 3" "1.1.1.3 - - [10/Oct/2000:13:55:38 -0700] \"GET /b HTTP/1.1\" 200 9"; run { in; field 9; tally }; want "200\t2" "404\t1" }
test "hits counts total requests" { given "1.1.1.1 - - [d] \"GET / HTTP/1.1\" 200 12" "1.1.1.2 - - [d] \"GET /a HTTP/1.1\" 404 3"; run { in; count }; want "2" }