Search
Varnish Enterprise

Real-time Status (rtstatus)

Description

The rtstatus vmod allows you to 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.

Numbers

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.

Usage

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);
  }
}

API

synthetic_json

VOID synthetic_json()

Returns a JSON object with relevant Varnish counters. Takes care of setting the content type.

Arguments: None

Type: Function

Returns: None

Restricted to: vcl_synth, vcl_backend_error

synthetic_html

VOID synthetic_html()

Renders in a UI the JSON file obtained from the synthetic_json function. Takes care of setting the content type.

Arguments: None

Type: Function

Returns: None

Restricted to: vcl_synth, vcl_backend_error

Availability

The rtstatus VMOD is available in Varnish Enterprise version 6.0.0r0 and later.


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203