Varnishncsa Random Log Sampling ?

Geoff Simmons geoff at
Mon Mar 2 12:18:15 UTC 2020

On 3/2/20 12:13, Yassine Aouadi wrote:
> Is there Any way to go further with  varnishncsa  and perform and random
> sampling of my access logs ? for example write only 10 % of access logs

I've done that with log queries in the varnishncsa or varnishlog command
line. For example, this query filters out all logs for which the
X-Varnish header does not end in 0:

	-q 'RespHeader:X-Varnish !~ "0$"'

The queries can use regular expressions, as this one does, so you can do
things like filter for the range [0-4], [02468] for the even numbers, or
whatever your imagination comes up with.

If you know that your site always produces a certain kind of content,
say a cookie whose value is hex digits, you can base your filter on
that, say something like [89a-f].

If you use that X-Varnish example, bear in mind that it only applies to
client logs. X-Varnish appears in backend request headers, so it would
have to be BereqHeader:X-Varnish.

** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the varnish-misc mailing list