1VARNISHNCSA(1)                                                  VARNISHNCSA(1)
2
3
4

NAME

6       varnishncsa - Display Varnish logs in Apache / NCSA combined log format
7

SYNOPSIS

9       varnishncsa  [-a]  [-b]  [-c] [-C] [-d] [-D] [-F <format>] [-f <format‐
10       file>] [-g <request|vxid>] [-h] [-L <limit>] [-n <dir>] [-P <file>] [-q
11       <query>]  [-r  <filename>]  [-R  <limit[/duration]>] [-t <seconds|off>]
12       [-V] [-w <filename>]
13

DESCRIPTION

15       The varnishncsa  utility  reads  varnishd(1)  shared  memory  logs  and
16       presents them in the Apache / NCSA "combined" log format.
17
18       Each  log  line  produced is based on a single Request type transaction
19       gathered from the shared memory log. The Request  transaction  is  then
20       scanned for the relevant parts in order to output one log line. To fil‐
21       ter the log lines produced, use the query language to select the appli‐
22       cable transactions. Non-request transactions are ignored.
23
24       The following options are available:
25
26       -a     When  writing  output  to a file, append to it rather than over‐
27              write it.
28
29       -b     Log backend requests. If -c is not specified, then only  backend
30              requests will trigger log lines.
31
32       -c     Log  client  requests.  This is the default. If -b is specified,
33              then -c is needed to also log client requests
34
35       -C     Do all regular expression and string matching caseless.
36
37       -d     Process log records at the head of the log and exit.
38
39       -D     Daemonize.
40
41       -F <format>
42              Set the output log format string.
43
44       -f <formatfile>
45              Read output format from a file. Will read a single line from the
46              specified file, and use that line as the format.
47
48       -g <request|vxid>
49              The  grouping  of  the  log  records. The default is to group by
50              vxid.
51
52       -h     Print program usage and exit
53
54       -L <limit>
55              Sets the upper limit of incomplete transactions kept before  the
56              oldest  transaction is force completed. A warning record is syn‐
57              thesized when this happens. This setting keeps an upper bound on
58              the  memory  usage of running queries. Defaults to 1000 transac‐
59              tions.
60
61       -n <dir>
62              Specify the varnishd working directory (also known  as  instance
63              name) to get logs from. If -n is not specified, the host name is
64              used.
65
66       -P <file>
67              Write the process' PID to the specified file.
68
69       -q <query>
70              Specifies the VSL query to use.
71
72       -r <filename>
73              Read log in binary file format from this file. The file  can  be
74              created with varnishlog -w filename.
75
76       -R <limit[/duration]>
77              Restrict the output to the specified limit. Transactions exceed‐
78              ing the limit will be suppressed. The limit is specified as  the
79              maximum  number  of  transactions  (with  respect  to the chosen
80              grouping method) and an optional time period. If no duration  is
81              specified,  a  default  of  s is used. The duration field can be
82              formatted as in VCL (e.g. -R 10/2m) or as a simple  time  period
83              without  the prefix (e.g. -R 5/m). When in -g raw grouping mode,
84              this setting can not be used alongside -i, -I, -x or -X, and  we
85              advise using -q instead.
86
87       -t <seconds|off>
88              Timeout before returning error on initial VSM connection. If set
89              the VSM connection is retried every 0.5 seconds  for  this  many
90              seconds.  If zero the connection is attempted only once and will
91              fail immediately if unsuccessful. If set to "off",  the  connec‐
92              tion will not fail, allowing the utility to start and wait inde‐
93              finetely for the Varnish instance to appear.  Defaults to 5 sec‐
94              onds.
95
96       -V     Print version information and exit.
97
98       -w <filename>
99              Redirect output to file. The file will be overwritten unless the
100              -a option was specified. If the application receives a SIGHUP in
101              daemon mode the file will be reopened allowing the old one to be
102              rotated away. This option is required  when  running  in  daemon
103              mode.
104
105       --optstring
106              Print the optstring parameter to getopt(3) to help writing wrap‐
107              per scripts.
108

MODES

110       The default mode of varnishncsa is "client mode".  In  this  mode,  the
111       log  will  be similar to what a web server would produce in the absence
112       of varnish.  Client mode can be explicitly selected by using -c.
113
114       If the -b switch is specified, varnishncsa  will  operate  in  "backend
115       mode".   In  this  mode,  requests generated by varnish to the backends
116       will be logged.  Unless -c is also specified, client requests  received
117       by varnish will be ignored.
118
119       When  running  varnishncsa  in  both  backend  and  client  mode, it is
120       strongly advised to include the format  specifier  %{Varnish:side}x  to
121       distinguish between backend and client requests.
122
123       Client  requests that results in a pipe (ie. return(pipe) in vcl), will
124       not generate logging in backend mode. This is because  varnish  is  not
125       generating  requests,  but  blindly passes on bytes in both directions.
126       However, a varnishncsa instance running in normal  mode  can  see  this
127       case by using the formatter %{Varnish:handling}x, which will be 'pipe'.
128
129       In  backend mode, some of the fields in the format string get different
130       meanings.  Most notably, the byte counting formatters (%b, %I, %O) con‐
131       siders varnish to be the client.
132
133       It  is possible to keep two varnishncsa instances running, one in back‐
134       end mode, and one in client mode, logging to different files.
135

FORMAT

137       Specify the log format to use. If no format is  specified  the  default
138       log format is used:
139
140          %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i"
141
142       Escape sequences \n and \t are supported.
143
144       Supported formatters are:
145
146       %b     In  client mode, size of response in bytes, excluding HTTP head‐
147              ers.  In backend mode, the number of  bytes  received  from  the
148              backend,  excluding  HTTP  headers.   In  CLF format, i.e. a '-'
149              rather than a 0 when no bytes are sent.
150
151       %D     In client mode, time taken to serve the  request,  in  microsec‐
152              onds.   In  backend  mode, time from the request was sent to the
153              entire body had been received.
154
155       %H     The request protocol. Defaults to HTTP/1.0 if not known.
156
157       %h     Remote host. Defaults to '-' if not known.  In backend mode this
158              is the IP of the backend server.
159
160       %I     In  client  mode,  total bytes received from client.  In backend
161              mode, total bytes sent to the backend.
162
163       %{X}i  The contents of request header X. If the header appears multiple
164              times in a single transaction, the last occurrence is used.
165
166       %l     Remote logname. Always '-'.
167
168       %m     Request method. Defaults to '-' if not known.
169
170       %{X}o  The  contents of response header X. If the header appears multi‐
171              ple times in a single transaction, the last occurrence is used.
172
173       %O     In client mode, total bytes sent to client.   In  backend  mode,
174              total bytes received from the backend.
175
176       %q     The query string. Defaults to an empty string if not present.
177
178       %r     The first line of the request. Synthesized from other fields, so
179              it may not be the request verbatim. See the NOTES section.
180
181       %s     Status sent to the client.  In  backend  mode,  status  received
182              from the backend.
183
184       %t     In  client  mode,  time  when  the request was received, in HTTP
185              date/time format.  In backend mode, time when  the  request  was
186              sent.
187
188       %{X}t  In  client mode, time when the request was received, in the for‐
189              mat specified by X.  In backend mode, time when the request  was
190              sent.   The  time  specification format is the same as for strf‐
191              time(3).
192
193       %T     In client mode, time taken to serve the request, in seconds.  In
194              backend  mode, time from the request was sent to the entire body
195              had been received.
196
197       %U     The request URL without the query string. Defaults to '-' if not
198              known.
199
200       %u     Remote user from auth.
201
202       %{X}x  Extended variables.  Supported variables are:
203
204              Varnish:time_firstbyte
205                     Time  from  when  the request processing starts until the
206                     first byte is sent to the client, in seconds.  For  back‐
207                     end  mode:  Time from the request was sent to the backend
208                     to the entire header had been received.
209
210              Varnish:hitmiss
211                     One of the 'hit' or 'miss' strings, depending on  whether
212                     the request was a cache hit or miss. Pipe, pass and synth
213                     are considered misses.
214
215              Varnish:handling
216                     One of the  'hit',  'miss',  'pass',  'pipe'  or  'synth'
217                     strings indicating how the request was handled.
218
219              Varnish:side
220                     Backend  or  client  side. One of two values, 'b' or 'c',
221                     depending on where the request was made. In pure  backend
222                     or client mode, this field will be constant.
223
224              Varnish:vxid
225                     The VXID of the varnish transaction.
226
227              VCL_Log:key
228                     The value set by std.log("key:value") in VCL.
229
230              VSL:tag:record-prefix[field]
231                     The  value of the VSL entry for the given tag-record pre‐
232                     fix-field combination. Tag is mandatory, the other compo‐
233                     nents are optional.
234
235                     The record prefix will limit the matches to those records
236                     that have this prefix as the first  part  of  the  record
237                     content followed by a colon.
238
239                     The  field  will,  if  present, treat the log record as a
240                     white space separated list of fields, and  only  the  nth
241                     part  of the record will be matched against. Fields start
242                     counting at 1 and run up to 255.
243
244                     Defaults to '-' when the tag is not seen, the record pre‐
245                     fix  does  not  match or the field is out of bounds. If a
246                     tag appears multiple times in a single  transaction,  the
247                     first occurrence is used.
248

SIGNALS

250       SIGHUP Rotate the log file (see -w option).
251
252       SIGUSR1
253              Flush any outstanding transactions.
254

NOTES

256       The  %r  formatter  is  equivalent to "%m http://%{Host}i%U%q %H". This
257       differs from apache's %r behavior, equivalent to "%m  %U%q  %H".   Fur‐
258       thermore,  when using the %r formatter, if the Host header appears mul‐
259       tiple times in a single transaction, the first occurrence is used.
260

EXAMPLE

262       Log the second field of the Begin record, corresponding to the VXID  of
263       the parent transaction:
264
265          varnishncsa -F "%{VSL:Begin[2]}x"
266
267       Log the entire Timestamp record associated with the processing length:
268
269          varnishncsa -F "%{VSL:Timestamp:Process}x"
270

SEE ALSO

272       varnishd(1) varnishlog(1) varnishstat(1) vsl(7)
273

HISTORY

275       The  varnishncsa utility was developed by Poul-Henning Kamp in coopera‐
276       tion with Verdens Gang AS and Varnish Software AS. This manual page was
277       initially  written  by  Dag-Erling  Smørgrav  <des@des.no>,  and  later
278       updated by Martin Blix Grydeland and Pål Hermunn Johansen.
279
281       This document is licensed under the same licence as Varnish itself. See
282       LICENCE for details.
283
284       · Copyright (c) 2006 Verdens Gang AS
285
286       · Copyright (c) 2006-2016 Varnish Software AS
287
288
289
290
291                                                                VARNISHNCSA(1)
Impressum