Skip to content

Instantly share code, notes, and snippets.

@marcofbb
Last active February 14, 2024 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcofbb/ccf6ff872456f4d168a279218ba24272 to your computer and use it in GitHub Desktop.
Save marcofbb/ccf6ff872456f4d168a279218ba24272 to your computer and use it in GitHub Desktop.
TOP and Logs command varnish 4
# Muestro las URL que se envian al backend
varnishtop -i BereqURL
# Muestro los host de peticiones al back
varnishtop -b -I BeReqHeader:Host
# Muestro todas URL peticionadas
varnishtop -i requrl
# Mostrar peticiones metodo
varnishtop -i reqMethod
# Mostrar HTTP status
varnishtop -i respStatus
# Mostrar peticiones metodo enviados al backend
varnishtop -i bereqMethod
# Top IP address
varnishtop -i ReqStart
# Top IP address proxy
varnishtop -C -I ReqHeader:X-Forwarded-For
# Top IP adress cloudflare
varnishtop -C -I ReqHeader:CF-Connecting-IP
# Top IP adress Sucuri Security
varnishtop -C -I ReqHeader:SUCURI-CLIENTIP
# Top Referer
varnishtop -C -I ReqHeader:Referer
# Top user agent
varnishtop -C -I ReqHeader:User-Agent
# Filtrar las redirecciones permanentes (301) y mostrar host url y destino
varnishlog -q "RespStatus ~ 301" -i "ReqURL" -I "ReqHeader:Host:" -I "RespHeader:Location:" -i "RespStatus"
# Filtrar por host, y mostrar ReqURL y Referer
varnishlog -q 'ReqHeader ~ "Host: (www\.)?example\.com"' -i "ReqURL" -I "ReqHeader:Referer:"
# Show the top piped URLs
varnishtop -b -i BereqUrl -q Begin "~" "pipe"
# Show the top missed URLs
varnishtop -i ReqURL -q 'VCL_call eq "MISS"'
# See HIT requests slower than 2 seconds
varnishtop -I Timestamp:Resp -q 'Timestamp:Resp ~ "\ [2-9]\." and VCL_call eq "HIT"'
# See all the logs from a specific domain
varnishlog -q '(ReqHeader:Host ~ "example.com.br" and ReqURL eq "/") or (BereqHeader:Host ~ "example.com.br" and BereqURL eq "/")'
# Ver IP cloudflare involucradas en error 403
varnishtop -q "RespStatus ~ 403" -I "ReqHeader:CF-Connecting-IP"
#BereqMethod,BereqURL,BereqHeader,BerespStatus,BerespHeader,reqMethod,reqURL,reqHeader,respStatus,respHeader,TTL,VCL_call,VCL_return,RespHeader
@marcofbb
Copy link
Author

# Buscar dirección IP en los logs para traer los datos de ReqHeader
varnishlog -q 'ReqHeader ~ "CF-Connecting-IP: 127.0.0.2"' -g request -i ReqHeader -I Host

@marcofbb
Copy link
Author

marcofbb commented Sep 1, 2023

# Listar todas las URL con error 500 
varnishlog -q "BerespStatus == 500" -i BereqURL -I BereqHeader:Host

@marcofbb
Copy link
Author

timeout 10s varnishncsa -F '%{CF-Connecting-IP}i %U %t' | grep '/search' | awk '{print $1}' | sort | uniq -c | sort -nr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment