0

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?

hvelarde
  • 133
  • 6

1 Answers1

0

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.

Danila Vershinin
  • 4,738
  • 3
  • 16
  • 21