Log backend name/ip
Cédric Jeanneret
varnish at tengu.ch
Mon Jun 29 11:26:57 CEST 2015
Hello,
I have a specific varnishncsa format, and I'm wanting to log the backend
used, especially when the request hits some director (either round_robin
or hash).
I think there would be two places in the VCL in order to log this
information:
* in vcl_backend_response
* in vcl_backend_error
Is this correct? If so, I seem to be unable to get the backend using, in
both cases, beresp.backend.ip
Here's how I do my stuff:
sub vcl_backend_response {
std.log("backend_used:" + beresp.backend.ip);
[… some other things…]
}
sub vcl_backend_error {
std.log("backend_used:" + beresp.backend.ip);
[… some other things…]
}
Then I fetch the entry using
"varnish.backend_name":"%{VCL_Log:backend_used}x"
in my varnishncsa formatted string (output as a JSON, there are many
other fields in there, of course).
Is this correct? Did I missed anything in order to ensure I actually get
the backend IP?
Thanks!
Cheers,
C.
More information about the varnish-misc
mailing list