4

I know that in Varnish you can add data to the cache hash using hash_data() within vcl_hash, as per the docs.

For debugging purposes, I would like to be able to see the entire contents of whatever is making up the hash.

For example, it would be really useful if we could do:

 # This won't work:
 set req.http.X-DEBUG = "HASH-DATA:" + hash_data();

Does anyone know if this is possible?

rangfu
  • 6,878
  • 2
  • 16
  • 17
  • `varnishlog` properly explains what hash data is used for that specific request. Is that not sufficient - gathering the data from there? – Debreczeni András Jul 17 '15 at 08:14
  • @debreczeni-andrás Yes that worked nicely for me, thanks. If you add this as an answer, I'll mark it as the accepted answer. – rangfu Jul 20 '15 at 10:18

2 Answers2

10

You can usually see it with the varnishlog command.

However, since varnish 5 you need to enable the hash specifically in the log output. This can be done with the varnishadm utility:

Execute varnishadm and on the prompt it starts, type:

varnish> param.set vsl_mask +Hash

you can exit the shell by typing quit, and then run varnishlog again, it should display the hash used on each request now.

ciencia
  • 456
  • 4
  • 11
1

varnishlog properly explains what hash data is used for a specific request.

You can redirect the varnishlog output to your custom file for further review:

varnishlog > my-log.log
Debreczeni András
  • 1,597
  • 10
  • 18
  • 4
    This doesn't seem to be the case anymore with Varnish 5. Am I supposed to see Hash data with varnishlog because I don't see anything other than the VCL_call to HASH and the VCL_return hash. There is no tag named Hash available. – Yanick Girouard Jul 19 '17 at 19:16