Varnish Logging Examples

Log failing (client side) requests:

  • varnishlog -c -m TxStatus:^50

Log only POST requests:

  • varnishlog -c -m RxRequest:POST

Log only the User-Agent string:

  • varnishlog -c -i RxHeader -I User-Agent

Log only requests where Varnish allows the browser to send some cookie through to the backend:

  • varnishlog -b -i TxURL,TxHeader -o TxHeader Cookie

Log the entire request made to the homepage by people using Mozilla/5.0 as User-Agent. (based on this:  http://err.no/personal/blog/2008/Dec/17#2008-12-17-10-14_poor_mans_filtering_language)

  • varnishlog -o -c | perl -ne 'BEGIN { $/ = "";} print if (/RxURL.*\/$/m and /RxHeader.*Mozilla\/5.0/);'

Log all requests that take more than 10 seconds to generate:

  • varnishlog -o -i Backend,RxURL,ReqEnd,RxHeader? | perl -ne ‘BEGIN { $/= “”;} print if (/ReqEnd(?:[\sc]+)\d+\s\d+.\d+\s+\d+.\d+\s+\d+.\d+\s+(\d+.\d+)/ and $1 > 10.0)’