7ed796f12ccb0f5c41e725621f26afce2e7c5172
Varnish Prometheus Business Exporter
Lightweight Python exporter for Varnish. It exposes /metrics for Prometheus and focuses on per-domain business/operational statistics rather than only raw counters.
Requirements
- Python 3
varnishstatvarnishlog- Access to Varnish shared memory/logs, usually by running as root or with proper permissions
No external Python dependencies are required.
Quick start
Only varnishstat:
python3 varnish_exporter.py --modules core,stat
Test VSL without sampling:
sudo python3 varnish_exporter.py --enable-vsl --vsl-sample 1 --profile full
Recommended production mode:
sudo python3 varnish_exporter.py \
--port 9131 \
--enable-vsl \
--profile standard \
--vsl-sample 0.001
Then check:
curl -s http://127.0.0.1:9131/metrics | grep varnish_domain
Profiles
minimal: rps, hit ratio, backend ratio, 5xx ratio, p95 latencystandard: recommended business-oriented domain statisticsfull: more detailed derived statisticsraw: full plus raw HTTP counters/histograms
Modules
core: exporter self metricsstat:varnishstat -1 -jvsl:varnishlog -g requestdomain: derived per-domain statisticsraw: raw request counters/histograms
Example:
sudo python3 varnish_exporter.py --modules core,stat,vsl,domain --profile standard
Domain grouping
Use config.example.json as a template:
sudo python3 varnish_exporter.py \
--config ./config.example.json \
--enable-vsl \
--profile standard
If no config is provided, the exporter uses the real Host header as the site label.
Important notes
- Varnish cannot measure real browser render time such as LCP/FCP/DOMContentLoaded.
- Latency here means server-side response time as observed by Varnish.
- For high traffic, avoid
--vsl-sample 1in production. - Start production with
--vsl-sample 0.001or0.0001.
Description
Languages
Python
100%