randy/knot-grafana.md
2026-08-02 15:48:27 -07:00

3.2 KiB

knot DNS - Prometheus - Grafana pipeline

I wanted Grafana style graphing of a knot DNS server's performance and load, and of the loads and contributions of the couple of hundred DNS zones on the server. I chose a Prometheus/Grafna pipeline because I did not really know of alternatives.

I wanted as little additional load on the DNS server, so wanted Prometheus and Grafana on another server. I happened to already have them from another measurement pipeline.

For this document, let's call the two servers knot.host and web.host. This is on Debian-13 trixie.

knot Configuration

I followed knot's documentation of configuring statitistics. So I created a minimal mod-stats:

mod-stats:
  - id: custom
    server-operation: on

I chose to invoke it it at the template, not per-zone, level, and had three knot templates. To each, I added the one line, as in

template:
  - id: default
    module: mod-stats/custom
    storage: <directory spec>
    semantic-checks: on
    file: %s

knot Export

To get the data out of the knot.host toward the web.host, i used the python version of knot-exporter. You'll also want to look at the page for the golang version, because it documents the command line paramaters.

To build knot-export, git clone it into /usr/local/src and untar it. First, to deal with python weirdness, you may have to do the venv kludge, so

apt install python3-venv

Then you can

cd knot_exporter-3.5.6
python3 -m venv venv
source venv/bin/activate
pip install -r knot_exporter.egg-info/requires.txt
pip install knot-exporter

The resulting ninary will be in knot.host:/usr/local/src/knot_exporter-3.5.6/venv/bin/knot-exporter, which you will use to

cat > /usr/lib/systemd/system/knot-exporter.service << EOF
[Unit]
Description=Knot prometheus exporter
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
WorkingDirectory=/run/knot
ExecStart= /usr/local/bin/knot-exporter --web-listen-addr 666.42.7.11 --web-listen-port 9443
SyslogIdentifier=knot-exporter

[Install]
WantedBy=multi-user.target
EOF

which I am sure can be improved by a systemd hacker.

Give it a start by

systemctl enable knot-exporter.service
systemctl start knot-exporter.service
systemctl status knot-exporter.service

Now check it is alive by

lsof -i :9443

And see if it is exporting data by browsing to http://knot.host:9443/metrics.

And that is it for the exporter.

Prometheus Import

As I already had the Prometheus server running, I could simply add the knot-exporter feed:

cat >> /etc/prometheus/prometheus.yml << EOF

  - job_name: 'knot_knot'
    scrape_interval: 30s
    static_configs:
      - targets: ['knot.host:9443']
EOF

And see if it is exporting data by browsing to http://web.host:9000/metrics.

Grafana

I already had a running Grafana. So I just needed dashboards. Robert hacked two up using <gasp!> Claude Opus 5. You can find them at Server Overview and Zone Stats.


2026.08.02