I'm using varnishncsa to log requests that are taking to long to be answered on my backend servers using the following command:

varnishncsa -F '%t "%r" %s %T' | awk '$7 > 10 {print}'

I was trying to add information on the backend name but this is not being displayed on varnishncsa output:

sub vcl_backend_response {
    std.log("backend_name:" + beresp.backend.name);

what I'm doing wrong?

1 Answer 1


It doesn't work for you because varnishncsa uses "client" mode by default. Enable it using -b switch.

Subsequently, this will work:

varnishncsa -b -F '%t "%r" %s %T %{VCL_Log:backend_name}x' | awk '$7 > 10 {print}'

You might want to check full explanation which includes additional optimization to query slow backend requests.

  • thanks! I'm using Varnish 4.1.1 and the varnishncsa command doesn't have the -b option: varnishncsa: invalid option -- 'b'; nice blog post, BTW.
    – hvelarde
    Commented Mar 22, 2017 at 19:28
  • Ah, bummer :) Works fine with Varnish 4.1.5 lol. Commented Mar 22, 2017 at 20:32
  • You might then want to put your std.log statement in vcl_recv instead and log the value of req.backend_hint - this will work. Commented Mar 22, 2017 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .