Go to file
Jacob Hoffman-Andrews 1de6c94faa
Update README with deployment models (#64)
2023-11-13 16:54:00 -08:00
.github/workflows Update dependencies to fix promhttp uncontrolled resource consumption (#51) 2023-02-21 16:42:51 -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
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
go.mod Update dependencies to fix promhttp uncontrolled resource consumption (#51) 2023-02-21 16:42:51 -05:00
go.sum Update dependencies to fix promhttp uncontrolled resource consumption (#51) 2023-02-21 16:42:51 -05:00
nfpm.yaml Build and Release Action (#38) 2022-04-22 11:28:46 -07:00
unbound_exporter.go Added cookie and max collision metrics (#61) 2023-11-13 16:53:46 -08: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