A vmod that lets you query your Varnish server for a JSON object containing counters.
Visiting the URL /rtstatus.json
on the Varnish server will produce an
application/json
response of the following format:
{
"uptime" : "0+16:12:58",
"uptime_sec": 58378.00,
"hitrate": 30.93,
"load": 2.73,
"varnish_version" : "[...]",
"server_id": "[...]",
"be_info":
[
{ "server_name": "[...]", "happy": [...], "bereq_tot": [...], [...] },
[...]
]
"[counter]": {"type": "[...]", "ident": "[...]", "descr": "[...]", "value": [...] },
[...]
}
It comes with a user interface in the form of a static web page that renders
the JSON file at the URL /rtstatus.html
.
In your VCL you can use this vmod along the following lines:
vcl 4.0;
import rtstatus;
sub vcl_recv {
if (req.url == "/rtstatus.json" || req.url == "/rtstatus.html") {
return (synth(200));
}
}
sub vcl_synth {
if (req.url == "/rtstatus.json") {
rtstatus.synthetic_json();
return (deliver);
}
if (req.url == "/rtstatus.html") {
rtstatus.synthetic_html();
return (deliver);
}
}
Varnish version: varnish version installed on your server.
Varnish uptime: child uptime.
Hit ratio: absolute hitrate ratio. It is evaluated as:
(n_hit) / (n_hit + n_miss)
Note that uptime is not taken into consideration for this counter.
Avg hitrate: average hitrate since uptime. It is evaluated as:
((n_hit) / (n_hit + n_miss)) / uptime
Avg load: average load since uptime. It is evaluated as:
n_requests / uptime
The list of counters is described in the varnish-counters(7)
manual, and for
convenience backend counters are grouped by backend in the be_info
field.