Useful Varnish 3.0 Commands: one-liners with varnishtop and varnishlog

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, June 29, 2011

Follow me on Twitter as @mattiasgeniar

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'

Requests made by a client

This shows only the “RxURL”, the URL being requested.

# varnishtop -i RxURL
# varnishlog -c | grep 'RxURL'

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: '

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: '

There’s plenty more useful & small Varnish commands, if you have some more feel free to add them to the comments!



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.