You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

Close

In this blog post, we will cover the steps to set up monitoring for BIND DNS server using Prometheus Server and Grafana to visualize Bind metrics. BIND which stands for “Berkeley Internet Name Domain” is an open-source Domain Name server that allows you to publish your DNS information on the Internet and allow network users to do DNS queries.

The number of tools that can be used to monitor BIND DNS server is limited, and personally, I like Prometheus Bind exporter with Grafana. LibreNMS has BIND application monitoring that I was planning to give it a try.

Setup Pre-requisites

Installed and configured BIND DNS server BIND need to have been build with libxml2 support. This can be confirmed using

# named -V | grep libxml2 using libxml2 version: 2.9.1

3. Installed Prometheus – Install Prometheus on Ubuntu / CentOS / Debian

Step 1: Install Bind Prometheus Exporter

Install wget

--- Ubuntu / Debian --- $ sudo apt -y install wget --- CentOS / Fedora --- $ sudo yum -y install wget

Download the latest release of bind_exporter binary:

curl -s https://api.github.com/repos/prometheus-community/bind_exporter/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -

This downloads a 64-bit binary release for Linux, for other operating systems, check the bind_exporter releases page.

Extract downloaded file.

tar xvf bind_exporter*.tar.gz

Move extracted binary file to /usr/local/bin directory:

cd bind_exporter-*/ sudo mv bind_exporter /usr/local/bin

Confirm installation by checking the version installed.

$ bind_exporter --version bind_exporter, version 0.3.0 (branch: HEAD, revision: c34ff3d6b4817f42e74b2b05b3797cf99683b4a9) build user: [email protected] build date: 20200109-18:54:09 go version: go1.12.14

You can print command options using bind_exporter --help

$ bind_exporter --help Usage of bind_exporter: -bind.pid-file string Path to Bind's pid file to export process information. (default "/run/named/named.pid") -bind.stats-groups value Comma-separated list of statistics to collect. Available: [server, view, tasks] (default "server,view,tasks") -bind.stats-url string HTTP XML API address of an Bind server. (default "http://localhost:8053/") -bind.stats-version string BIND statistics version. Can be detected automatically. Available: [xml.v2, xml.v3, auto] (default "auto") -bind.timeout duration Timeout for trying to get stats from Bind. (default 10s) -version Print version information. -web.listen-address string Address to listen on for web interface and telemetry. (default ":9119") -web.telemetry-path string Path under which to expose metrics. (default "/metrics")

Step 2: Configure BIND DNS server

You need to configure BIND to open a statistics channel. Since the exporter and BIND are on the same host, the port is opened locally.

For CentOS ISC BIND DNS server, edit the file /etc/named.conf to add.

statistics-channels { inet 127.0.0.1 port 8053 allow { 127.0.0.1; }; };

For Ubuntu / Debian ISC BIND DNS server, edit the file /etc/bind/named.conf.options

statistics-channels { inet 127.0.0.1 port 8053 allow { 127.0.0.1; }; };

Restart bind for the changes to be effected

sudo systemctl restart named

Step 3: Create Bind Exporter systemd service

The next part is to create systemd service used to start the collector with access to the bind(named) pid file and enable the view stats group:

Add Prometheus system user account:

sudo groupadd --system prometheus sudo useradd -s /sbin/nologin --system -g prometheus prometheus

This user will manage the exporter service. Once the user account has been added, create a systemd service unit file:

sudo tee /etc/systemd/system/bind_exporter.service<<EOF [Unit] Description=Prometheus Documentation=https://github.com/digitalocean/bind_exporter Wants=network-online.target After=network-online.target [Service] Type=simple User=prometheus Group=prometheus ExecReload=/bin/kill -HUP $MAINPID ExecStart=/usr/local/bin/bind_exporter \ --bind.pid-file=/var/run/named/named.pid \ --bind.timeout=20s \ --web.listen-address=0.0.0.0:9153 \ --web.telemetry-path=/metrics \ --bind.stats-url=http://localhost:8053/ \ --bind.stats-groups=server,view,tasks SyslogIdentifier=prometheus Restart=always [Install] WantedBy=multi-user.target EOF

Reload systemd and start bind_exporter service:

sudo systemctl daemon-reload sudo systemctl restart bind_exporter.service

Enable the service to start on boot:

sudo systemctl enable bind_exporter.service

Confirm that the service is listening on port 9153 as configured

$ sudo ss -tunelp | grep 9153 tcp LISTEN 0 128 :::9153 :::* users:(("bind_exporter",pid=23266,fd=3)) uid:997 ino:113951 sk:ffff8d17fab19980 v6only:0 <->

Open the port on the firewall if you have firewalld running:

sudo firewall-cmd --add-port=9153/tcp --permanent sudo firewall-cmd --reload

Step 4: Configure Prometheus Server

If you don’t have a running Prometheus server, refer to our previous guide on how to Install Prometheus Server on CentOS and Ubuntu Linux. Below is a definition of my two jobs

- job_name: dns-master static_configs: - targets: ['10.1.5.3:9153'] labels: alias: dns-master - job_name: dns-slave1 static_configs: - targets: ['10.1.5.4:9153'] labels: alias: dns-slave

Restart prometheus server:

sudo systemctl restart prometheus

Step 5: Add Grafana Dashboard

We’re going to use already created Grafana dashboard by Cristian Calin. Dashboard ID is 1666 . Login to Grafana and Add Prometheus data source if you haven’t.

When Prometheus data source has been added, import Bind Grafana Dashboard by navigating to Dashboard > Import. Use 1666 for Grafana Dashboard ID.

Give it a descriptive name and choose Prometheus data source added earlier.

Click “Import” button to start using the dashboard. After a few minutes, the metrics should start showing.

Stay tuned for more monitoring guides with Prometheus and Grafana. Other monitoring guides are:

How to Monitor Linux Server Performance with Prometheus and Grafana in 5 minutes

How To Monitor Etcd Cluster with Prometheus and Grafana

How to Monitor Apache Web Server with Prometheus and Grafana in 5 minutes

Monitoring MySQL / MariaDB with Prometheus in five minutes