Last active
November 9, 2023 11:12
-
-
Save skinsch/8e55a08eb8b2315a36ad0dab6a0642cd to your computer and use it in GitHub Desktop.
Varnish Quick Reference Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check this too | |
# https://docs.fastly.com/guides/vcl/vcl-regular-expression-cheat-sheet | |
Health check backend servers: | |
varnishadm debug.health | |
Show requests that generate a 404 error: | |
varnishlog -q 'RespStatus == "404"'|egrep -i "ReqURL|ReqHeader Host:|Forwarded-For" | |
Show full requests for any 404 errors, 503, etc... | |
varnishlog -q 'RespStatus == 404' -g request | |
Show full request for a URL that has "wolf" in it... | |
varnishlog -q request -q 'ReqURL ~ "wolf"' | |
Get the top request methods | |
varnishtop -i ReqRequest | |
Top urls that missed the cache. | |
varnishtop -i RespURL | |
Top urls that HIT the cache. | |
varnishtop -i ReqURL | |
All urls that MISSED the cache in real time | |
varnishlog -i RespURL | |
Most frequent cookies: | |
varnishtop -i ReqHeader -I Cookie | |
Continually updated list of frequent URLs: | |
varnishtop -i ReqURL | |
Most frequent UA strings: | |
varnishtop -i ReqHeader -C -I ^User-Agent | |
Frequent charset (Accept-Charset can be replaced with any other HTTP header): | |
varnishtop -i ReqHeader -C -I '^Accept-Charset' | |
View top useragents: | |
varnishtop -C -b -i RespHeader -I "user-agent" | |
Top X-Robots-Tags (backend, front-end and object) | |
varnishtop -i RespHeader -I '^X-Robots-Tag' | |
Traffic sources: | |
varnishtop -i ReqHeader -I \^Referer | |
which pages are getting hit overall | |
varnishncsa | awk '{print $7}' | |
Which pages the IP address 127.0.0.1 is hitting: | |
varnishncsa | grep 192.168.1.31 | awk '{print $7}' | |
# | |
# -m Option: Some May not work.. i.e. -m with Varnish v4 - SK | |
# | |
Requests resulting in 404's: | |
varnishlog -b -m "ReqStatus:404" | |
IP addresses hitting the /clients URL: | |
varnishlog -m 'ReqURL:/clients' |grep 'X-Forwarded-For' | |
# | |
# -o Option: Some May not work.. i.e. -o with Varnish v4 - SK | |
# | |
All urls that hit the cache in real time. | |
varnishlog -o VCL_call hit | grep ReqURL | |
Look at an incoming client request of a specific URL: | |
varnishlog -c -o ReqURL index.html | |
Look at a backend request of a specific URL: | |
varnishlog -b -o TxURL index.html | |
See requests for one specific Hostname: | |
varnishlog -c -o ReqHeader "Host: example.com" | |
See the age of the cache objects for a specific hostname: | |
varnishlog -c -o ReqHeader "Host: example.com" | grep Age |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the overview!
Note: The command for
Top urls that HIT the cache.
andContinually updated list of frequent URLs:
are both the same, according to this document.The command
varnishtop -i ReqURL
only provides acontinually updated list
which also includes PASSed requests. SoTop urls that HIT the cache.
is wrong in this case.