Go to file
Phil Porada ab17c00752
Track memory used by DoH buffers (#72)
2024-01-30 10:17:11 -05:00
.github/workflows Add Dockerfile, compose.yaml, and an unbound example config (#66) 2023-11-17 13:12:02 -05:00
contrib Add contrib directory (#45) 2023-02-22 18:22:22 -05:00
.gitignore Refactored the unbound histogram metrics from gauge metrics into 2017-10-19 16:10:25 +02:00
Dockerfile Add Dockerfile, compose.yaml, and an unbound example config (#66) 2023-11-17 13:12:02 -05:00
LICENSE Add a proper license. 2017-01-09 09:35:52 +01:00
README.md Update README with deployment models (#64) 2023-11-13 16:54:00 -08:00
docker-compose.yml Add metric for num.rpz.action (#70) 2024-01-08 15:07:44 -05:00
droplist.zone Add metric for num.rpz.action (#70) 2024-01-08 15:07:44 -05:00
go.mod Update prometheus dependencies (#67) 2023-11-17 18:20:54 -05:00
go.sum Update prometheus dependencies (#67) 2023-11-17 18:20:54 -05:00
integration_test.go Track memory used by DoH buffers (#72) 2024-01-30 10:17:11 -05:00
nfpm.yaml Build and Release Action (#38) 2022-04-22 11:28:46 -07:00
unbound-example.conf Add metric for num.rpz.action (#70) 2024-01-08 15:07:44 -05:00
unbound_exporter.go Track memory used by DoH buffers (#72) 2024-01-30 10:17:11 -05:00
unbound_exporter_test.go Fix lints, add testing file, and update go mod and sum files (#28) 2021-11-17 14:32:28 -05:00

README.md

Prometheus Unbound exporter

This repository provides code for a simple Prometheus metrics exporter for the Unbound DNS resolver. This exporter connects to Unbounds TLS control socket and sends the stats_noreset command, causing Unbound to return metrics as key-value pairs. The metrics exporter converts Unbound metric names to Prometheus metric names and labels by using a set of regular expressions.


Prerequisites

Go 1.20 or above is required.

Installation

go install github.com/letsencrypt/unbound_exporter@latest

This will install the binary in $GOBIN, or $HOME/go/bin if $GOBIN is unset.

Updating dependencies

go get -u
go mod tidy

Usage - Unix socket

The simplest way to run unbound_exporter is on the same machine as your Unbound instance, connecting via a Unix socket. First, make sure you have this in your unbound.conf:

remote-control:
  control-enable: yes
  control-interface: /run/unbound.ctl

Then, arrange to run this on the same machine:

unbound_exporter -unbound.ca "" -unbound.cert "" -unbound.host "unix:///run/unbound.ctl"

Metrics will be exported under /metrics, on port 9167, on all interfaces.

$ curl 127.0.0.1:9167/metrics | grep '^unbound_up'
unbound_up 1

Usage - TLS

The more complicated way to run unbound_exporter is to configure unbound's control-interface with a TLS certificate from a private CA, and run unbound_exporter on a separate host. This is more of a hassle because you have to keep the certificate up to date and distribute the private CA to the host that unbound_exporter runs on.

See https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/configuration.html#set-up-remote-control for instructions on setting up the certificates and keys for remote-control via TLS. On the unbound_exporter side you will need to set the -unbound.ca, -unbound.cert, and -unbound.key flags to point to valid files that will trust the Unbound server's certificate and be trusted by Unbound in return.

Extended statistics

From the Unbound statistics doc: Unbound has an option to enable extended statistics collection. If enabled, more statistics are collected, for example what types of queries are sent to the resolver. Otherwise, only the total number of queries is collected. Add the following to your unbound.conf.

server:
    extended-statistics: yes