Here are some useful examples of varnishtop and varnishlog at work.
Displays a continuously updated list of the most frequently requested URLs:
varnishtop -i RxURL
varnishlog -c | grep 'RxURL'
Top requests to your backend. This shows only the "TxURL", the URL being retrieved from your backend.
varnishtop -i TxURL
varnishlog -b | grep 'TxURL'
#See what cookies values are the most commonly 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: '
#Accept-Encoding will show the most popular Accept-Encoding header the client are sending you.
varnishtop -i RxHeader -I
See what useragents are the most common from the clients
varnishtop -i RxHeader -C -I ^User-Agent
See what user agents are commonly accessing the backend servers, compare to the previous one to find clients that are commonly causing misses.
varnishtop -i TxHeader -C -I ^User-Agent
See what accept-charsets are used by clients
varnishtop -i RxHeader -I '^Accept-Charset
Listing all details about requests resulting in a 500/404 status:
varnishlog -b -m "RxStatus:500"
varnishlog -b -m "RxStatus:404"
References
- http://book.varnish-software.com/3.0/Getting_started.html
- https://www.varnish-cache.org/docs/3.0/reference/varnishlog.html
- https://www.varnish-cache.org/docs/3.0/reference/varnishtop.html
- https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html
- https://www.varnish-cache.org/docs/3.0/tutorial/logging.html#tutorial-logging
- https://ma.ttias.be/useful-varnish-3-0-commands-one-liners-with-varnishtop-and-varnishlog/
- http://stackoverflow.com/questions/13247707/how-to-read-output-of-varnishtop
- http://www.eldefors.com/varnish-command-line-tools/
- https://www.varnish-cache.org/trac/wiki/