• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.vscode/H18-Dec-2020-6159

dashboards/jonnenauha/H18-Dec-2020-1,4461,445

test/H18-Dec-2020-9,5119,505

vendor/H03-May-2022-320,601263,159

.gitignoreH A D18-Dec-202066 63

.travis.ymlH A D18-Dec-20202.2 KiB4437

CHANGELOG.mdH A D18-Dec-20205 KiB8860

ISSUE_TEMPLATE.mdH A D18-Dec-2020110 74

LICENSEH A D18-Dec-20201.1 KiB2217

README.mdH A D18-Dec-20205.3 KiB8752

build.shH A D18-Dec-20202 KiB6748

go.modH A D18-Dec-2020118 63

go.sumH A D18-Dec-202039.6 KiB408407

main.goH A D18-Dec-20207.5 KiB261209

prometheus.goH A D18-Dec-20209 KiB340283

utils.goH A D18-Dec-20202.4 KiB132105

varnish.goH A D18-Dec-20208.5 KiB347297

varnish_test.goH A D18-Dec-20208.4 KiB293258

README.md

1[![Build Status](https://travis-ci.com/jonnenauha/prometheus_varnish_exporter.svg?branch=master)](https://travis-ci.com/github/jonnenauha/prometheus_varnish_exporter)
2
3# Varnish exporter for Prometheus
4
5![Grafana example](dashboards/jonnenauha/dashboard.png)
6
7Scrapes the `varnishstat -j` JSON output on each Prometheus collect and exposes all reported metrics. Metrics with multiple backends or varnish defined identifiers (e.g. `VBE.*.happy SMA.*.c_bytes LCK.*.creat`) and other metrics with similar structure (e.g. `MAIN.fetch_*`) are combined under a single metric name with distinguishable labels. Vanish naming conventions are preserved as much as possible to be familiar to Varnish users when building queries, while at the same time trying to following Prometheus conventions like lower casing and using `_` separators.
8
9Handles runtime Varnish changes like adding new backends via vlc reload. Removed backends are reported by `varnishstat` until Varnish is restarted.
10
11Advanced users can use `-n -N`, they are passed to `varnishstat`.
12
13I have personally tested the following versions of Varnish to work `6.0.0, 5.2.1, 5.1.2, 4.1.1, 4.1.0, 4.0.3 and 3.0.5`. Missing category groupings in 3.x like `MAIN.` are detected and added automatically for label names to be consistent across versions, assuming of course that the Varnish project does not remove/change the stats.
14
15I won't make any backwards compatibility promises at this point. Your built queries can break on new versions if metric names or labels are refined. If you find bugs or have feature requests feel free to create issues or send PRs.
16
17# Installing and running
18
19You can find the latest binary releases for linux, darwin, windows, freebsd, openbsd and netbsd from the [github releases page](https://github.com/jonnenauha/prometheus_varnish_exporter/releases).
20
21By default the exporter listens on port 9131. See `prometheus_varnish_exporter -h` for available options.
22
23To test that `varnishstat` is found on the host machine and to preview all exported metrics run
24
25    prometheus_varnish_exporter -test
26
27# Troubleshooting
28
29> Could not get hold of varnishd, is it running?
30>
31> 2020/12/18 20:22:33 [FATAL] Startup test: varnishstat scrape failed: exit status 1
32
33User you are executing as can't find or access varnish services. `sudo` is a hammer that works, see for proper solutions [#62](https://github.com/jonnenauha/prometheus_varnish_exporter/issues/62).
34
35# Docker
36
37Scraping metrics from Varnish running in a docker container is possible since 1.4.1. Resolve your Varnish container name with `docker ps` and run the following. This will use `docker exec <container-name>` to execute varnishstat inside the spesified container.
38
39    prometheus_varnish_exporter -docker-container-name <container_name>
40
41I still don't have a easy, clear and user friendly way of running this exporter in a docker container. For community efforts and solutions see [this issue](https://github.com/jonnenauha/prometheus_varnish_exporter/issues/25#issuecomment-492546458).
42
43# Grafana dashboards
44
45You can download my dashboard seen in the above picture [here](dashboards/jonnenauha/dashboard.json). I use it at work with our production Varnish instances. I would be interested in your dashboards if you wish to share them or improvement ideas to my current one.
46
47# Varnish 4 and VCL UUIDs
48
49Starting with version 1.2 `backend` and `server` labels are always set. For backend-related metrics and Varnish 4 the `server` tag will be set to the VCL UUIDs for that backend. Note that there might be multiple VCLs loaded at the same time and the `server` tag might not be meaningful in that case.
50
51To aggregate all loaded VCLs into per-backend metric the following Prometheus [recording rules](https://prometheus.io/docs/querying/rules/) are recommended:
52
53    backend:varnish_backend_bereq_bodybytes:sum = sum(varnish_backend_bereq_bodybytes) without (server)
54    backend:varnish_backend_bereq_hdrbytes:sum = sum(varnish_backend_bereq_hdrbytes) without (server)
55    backend:varnish_backend_beresp_bodybytes:sum = sum(varnish_backend_beresp_bodybytes) without (server)
56    backend:varnish_backend_beresp_hdrbytes:sum = sum(varnish_backend_beresp_hdrbytes) without (server)
57    backend:varnish_backend_conn:sum = sum(varnish_backend_conn) without (server)
58    backend:varnish_backend_happy:sum = sum(varnish_backend_happy) without (server)
59    backend:varnish_backend_pipe_hdrbytes:sum = sum(varnish_backend_pipe) without (server)
60    backend:varnish_backend_pipe_in:sum = sum(varnish_backend_pipe_in) without (server)
61    backend:varnish_backend_pipe_out:sum = sum(varnish_backend_pipe_out) without (server)
62    backend:varnish_backend_req:sum = sum(varnish_backend_req) without (server)
63
64# Build
65
66**One time setup**
67
68This repot support go modules so out of `GOPATH` builds are supported. This makes development and buildings easier for go "novices".
69
70You need go 1.11 or higher, otherwise you can keep using `GOPATH` based development ([see old README](https://github.com/jonnenauha/prometheus_varnish_exporter/blob/1.4.1/README.md#build)).
71
721. [Install latest go](https://golang.org/doc/install) or use OS repos `golang` package.
73
74**Development**
75
76```bash
77# clone
78git clone git@github.com:jonnenauha/prometheus_varnish_exporter.git
79cd prometheus_varnish_exporter
80
81# build binary to current directory
82go build
83
84# release with cross compilation
85./build.sh <version>
86```
87