ToiVietBlog - Bài này mình sẽ hướng dẫn bạn monitor Bind9 DNS với Prometheus bind_exporter.
Trên Linux thì chắc hẳn bạn đã biết và quen với dịch vụ dns bind9. Thông thường các công ty, data center đều sẽ có hệ thống dns nội bộ.
Và là dịch vụ cung cấp cho toàn hệ thống, bạn cũng cần phải monitor nó chứ. Hệ thống demo của mình sử dụng Ubuntu server 18.04 LTS.
Cài đặt bind_exporter
Việc cài đặt bind_exporter trên Ubuntu 18.04 khá đơn giản. Ubuntu đã hỗ trợ sẵn gói cài đặt, gói này được build từ repository của Digital Ocean.
Các bước thực hiện dưới đây, bạn thực hiện nó trên các server DNS nhé.
Trước tiên, bạn cần tạo user system có tên prometheus
. Vì dịch vụ bind_exporter sẽ sử dụng user này.
groupadd --system prometheus grep prometheus /etc/group useradd -s /sbin/nologin -r -g prometheus prometheus
Tiếp theo, bạn gõ lệnh dưới để cài đặt exporter.
apt install prometheus-bind-exporter -y
Mở file config local.
nano /etc/bind/named.conf.local
Thêm nội dung dưới vào cuối file.
statistics-channels { inet 127.0.0.1 port 8053 allow { 127.0.0.1; }; };
Sau đó bạn reload dịch vụ bind9 và khởi động dịch vụ bind exporter.
service bind9 reload service prometheus-bind-exporter restart
Tới đây thì phần cài đặt đã xong.
Thiết lập prometheus cho bind_exporter
Bây giờ, bạn login vào server prometheus, thực hiện thiết lập cho bind_exporter.
nano /etc/promtheus/prometheus.yml
Copy nội dung dưới vào cuối file. Bạn thay các ip server trong nội dung dưới với ip/hostname server thực tế của bạn nhé.
- job_name: 'bind_exporter' scrape_interval: 15s metrics_path: '/metrics' static_configs: - targets: - ip-server-dns01:9119 - ip-server-dns02:9119
Bạn lưu ý là cần mở port 9119 giữa server prometheus và các server dns nhé.
Sau đó bạn reload lại dịch vụ prometheus.
systemctl reload prometheus
Thiết lập dashboard Grafana cho Bind9 DNS
Trong readme github của bind_exporter cũng đã đề cập đến dashboard grafana có ID là 12309.
Dashboard này làm khá hoàn chỉnh và làm cho exporter này. Nên bạn có thể yên tâm import nó mà không gặp lỗi gì.

Kết luận
Vậy là mình đã hướng dẫn các bạn thực hiện xong việc cài đặt và thiết lập monitor bind9 dns với prometheus bind_exporter. Kết quả bạn đạt được là một giao diện trực quan như hình ở trên.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.