Prometheus exporter for Unbound DNS statistics. Connects via Unix socket and exports metrics for monitoring DNS performance.
Inspired by ar51an/unbound-exporter, rewritten with simpler architecture (Unix socket only, no TLS).
- Go 1.19+
- Unbound with control socket enabled
Enable the control socket in /etc/unbound/unbound.conf:
remote-control:
control-enable: yes
control-interface: /run/unbound.ctl
Restart Unbound and verify the socket exists:
sudo systemctl restart unbound
ls -la /run/unbound.ctlThe exporter user needs read access to the socket. Either run as the unbound user (recommended) or add your user to the unbound group.
go mod tidy
go build -o unbound-exporter exporter.go./unbound-exporter --socket-path=/run/unbound.ctl --listen-address=0.0.0.0:9167Options:
-l, --listen-address Address to listen on (default "0.0.0.0:9167")
-m, --metrics-path Path to expose metrics (default "/metrics")
-s, --socket-path Path to Unbound control socket (default "/run/unbound.ctl")
--log-level Log level: debug, info, warn, error (default "info")
-t, --timeout Timeout for Unbound queries (default 5s)
sudo cp unbound-exporter /usr/local/bin/
sudo cp unbound-exporter.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now unbound-exporterscrape_configs:
- job_name: unbound
static_configs:
- targets: ['localhost:9167']Import dashboard.json into Grafana. Uses ${DS_PROMETHEUS} variable for datasource.
unbound_queries_total- Total DNS queriesunbound_cache_hit_total- Cache hitsunbound_cache_miss_total- Cache missesunbound_recursion_time_avg_seconds- Average recursion timeunbound_memory_caches_bytes{cache}- Memory by cache typeunbound_query_types_count{type}- Queries by record type (A, AAAA, etc.)unbound_answer_rcodes_count{rcode}- Responses by code (NOERROR, NXDOMAIN, etc.)unbound_response_time_buckets{lower,upper}- Response time distributionunbound_time_up_seconds{uptime}- Server uptime
MIT