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

Tired of the privacy invasion of browsers? Worried about the risk of seeing ads everywhere? Give the Brave Browser a try. All Chrome extensions are compatible. None of the telemetry. Auto-blocks ads and still support content creators like me.

Download the Brave browser now »

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.