Here are some useful commands if you’re toying around with Varnish and want to get some more insight into what’s happening. Varnishtop will show you the hits you’re getting in a “top”-like style, so the most active hits are shown on top. Varnishlog simply iterates over all logs and displays them as you would tail a normal log-file.
Top requests to your backend#
This shows only the “TxURL”, the URL being retrieved from your backend.
# varnishtop -i TxURL
# varnishlog -b | grep 'TxURL'
On Varnish 4.0 and newer the TxURL tag was renamed to BereqURL:
# varnishtop -i BereqURL
# varnishlog -b | grep 'BereqURL'
Requests made by a client#
This shows only the “RxURL”, the URL being requested.
# varnishtop -i RxURL
# varnishlog -c | grep 'RxURL'
On Varnish 4.0 and newer the RxURL tag was renamed to ReqURL:
# varnishtop -i ReqURL
# varnishlog -c | grep 'ReqURL'
Show cookies being sent by clients#
This will list all HTTP headers with a “Cookie” keyword in the request that are being sent to Varnish.
# varnishtop -i RxHeader -I Cookie
# varnishlog -c | grep 'Cookie: '
On Varnish 4.0 and newer the RxHeader tag was renamed to ReqHeader:
# varnishtop -i ReqHeader -I Cookie
# varnishlog -c | grep 'Cookie: '
Which host is being requested the most#
Only really useful when you’re serving multiple hosts in Varnish.
varnishtop -i RxHeader -I '^Host:'
varnishlog -i RxHeader | grep 'Host: '
On Varnish 4.0 and newer the RxHeader tag was renamed to ReqHeader:
varnishtop -i ReqHeader -I '^Host:'
varnishlog -i ReqHeader | grep 'Host: '
There’s plenty more useful & small Varnish commands, if you have some more feel free to add them to the comments!