Collecting varnish stats at the Url Level

Thomas Lecomte thomas.lecomte at virtual-expo.com
Mon May 2 07:52:11 CEST 2016


On Mon, May 2, 2016 at 7:00 AM, Debraj Manna <subharaj.manna at gmail.com> wrote:
> Thanks Thomas.
>
> How can I maintain a counter per url. In vcl_deliver obj.hits will again
> give me the overall hits.

As I said, you have to implement this yourself using VCL and varnishncsa.

Example of VCL:

      # 38. match rule for PDF pages
      if (req.url ~ "^\/pdf\/([^\/]+)\-(\d+)\.html$")
      {
        set req.http.X-MatchRule = "38";
        return (hash);
      }
      [...]
      std.log("MR:" + req.http.X-MatchRule);

Then, call varnishncsa with -F and %{VCL_Log:MR} plus
%{Varnish:handling} to log the match rule and the handling of the
request (miss, hit, pipe, pass, whatever). You will have to parse this
output yourself to compute a ratio.

-- 
Thomas Lecomte / Virtual Expo



More information about the varnish-misc mailing list