Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Varnish exporter for Prometheus

License

NotificationsYou must be signed in to change notification settings

jonnenauha/prometheus_varnish_exporter

Repository files navigation

Build Status

Varnish exporter for Prometheus

Grafana example

Scrapes thevarnishstat -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.

Handles runtime Varnish changes like adding new backends via vlc reload. Removed backends are reported byvarnishstat until Varnish is restarted.

Advanced users can use-n -N, they are passed tovarnishstat.

I have personally tested the following versions of Varnish to work6.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 likeMAIN. 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.

I 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.

Installing and running

You can find the latest binary releases for linux, darwin, windows, freebsd, openbsd and netbsd from thegithub releases page.

By default the exporter listens on port 9131. Seeprometheus_varnish_exporter -h for available options.

To test thatvarnishstat is found on the host machine and to preview all exported metrics run

prometheus_varnish_exporter -test

Troubleshooting

Could not get hold of varnishd, is it running?

2020/12/18 20:22:33 [FATAL] Startup test: varnishstat scrape failed: exit status 1

User you are executing as can't find or access varnish services.sudo is a hammer that works, see for proper solutions#62.

Docker

Scraping metrics from Varnish running in a docker container is possible since 1.4.1. Resolve your Varnish container name withdocker ps and run the following. This will usedocker exec <container-name> to execute varnishstat inside the spesified container.

prometheus_varnish_exporter -docker-container-name <container_name>

I still don't have a easy, clear and user friendly way of running this exporter in a docker container. For community efforts and solutions seethis issue.

Grafana dashboards

You can download my dashboard seen in the above picturehere. 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.

Varnish 4 and VCL UUIDs

Starting with version 1.2backend andserver labels are always set. For backend-related metrics and Varnish 4 theserver tag will be set to the VCL UUIDs for that backend. Note that there might be multiple VCLs loaded at the same time and theserver tag might not be meaningful in that case.

To aggregate all loaded VCLs into per-backend metric the following Prometheusrecording rules are recommended:

backend:varnish_backend_bereq_bodybytes:sum = sum(varnish_backend_bereq_bodybytes) without (server)backend:varnish_backend_bereq_hdrbytes:sum = sum(varnish_backend_bereq_hdrbytes) without (server)backend:varnish_backend_beresp_bodybytes:sum = sum(varnish_backend_beresp_bodybytes) without (server)backend:varnish_backend_beresp_hdrbytes:sum = sum(varnish_backend_beresp_hdrbytes) without (server)backend:varnish_backend_conn:sum = sum(varnish_backend_conn) without (server)backend:varnish_backend_happy:sum = sum(varnish_backend_happy) without (server)backend:varnish_backend_pipe_hdrbytes:sum = sum(varnish_backend_pipe) without (server)backend:varnish_backend_pipe_in:sum = sum(varnish_backend_pipe_in) without (server)backend:varnish_backend_pipe_out:sum = sum(varnish_backend_pipe_out) without (server)backend:varnish_backend_req:sum = sum(varnish_backend_req) without (server)

Build

One time setup

This repot support go modules so out ofGOPATH builds are supported. This makes development and buildings easier for go "novices".

You need go 1.11 or higher, otherwise you can keep usingGOPATH based development (see old README).

  1. Install latest go or use OS reposgolang package.

Development

# clonegit clone git@github.com:jonnenauha/prometheus_varnish_exporter.gitcd prometheus_varnish_exporter# build binary to current directorygo build# release with cross compilation./build.sh<version>

About

Varnish exporter for Prometheus

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp