Log backend name/ip

Cédric Jeanneret varnish at tengu.ch
Mon Jun 29 11:26:57 CEST 2015


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
* 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

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?




More information about the varnish-misc mailing list