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

Mattias Geniar, Wednesday, June 29, 2011 - last modified: Sunday, February 19, 2012

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!



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. Currently working on DNS Spy. Follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

beihan Wednesday, January 23, 2013 at 10:56

hello ,i use varnishtop display data real-time
but i don’t what is mean the three column?
and how to show full url ?
thanks

Reply


brablc Tuesday, March 26, 2013 at 13:49

I’m adding an header which allows me to flter using backend and/or host and/or URL on installations with multiple hosts and backends:

set req.http.X-Full-Url = req.backend ” ” req.http.host req.url ;

Reply


Craig Thursday, August 29, 2013 at 21:53

I’d love to modify the following to show me files that were being called twice.

Obviously the first time something gets called, it’ll show up in TxURL… But how do I discover what’s getting ‘missed’ and called multiple times?

varnishlog -b | grep ‘TxURL’

Reply


Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links