使用Prometheus監控bind9的DNS服務


  • 首先編譯bind_exporter,編譯方式參見bind_exporter
  • 創建一個systemd配置文件來運行bind_exporter
vi /etc/systemd/system/bind_exporter.service

內容如下,注意此處的用戶和組使用與named程序相同的用戶和組“named”。--web.listen-address為對外暴露的metric地址和端口,Prometheus從此處抓取bind_exporter的metrics;--bind.stats-url為本地bind服務綁定的地址和IP

[Unit]
Description=bind_exporter
Documentation=https://github.com/digitalocean/bind_exporter
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=named
Group=named
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/opt/bind_exporter/bind_exporter \
  --bind.pid-file=/var/run/named/named.pid \
  --bind.timeout=20s \
  --web.listen-address=0.0.0.0:9119 \
  --web.telemetry-path=/metrics \
  --bind.stats-url=http://localhost:53/ \
  --bind.stats-groups=server,view,tasks

SyslogIdentifier=bind_exporter
Restart=always

[Install]
WantedBy=multi-user.target
  • 加載並啟動bind_export
systemctl daemon-reload
systemctl restart bind_exporter.service
  • 在/etc/named.conf中添加如下內容,注意“statistics-channels”是與“options”並列的,而不是位於“options”內部
statistics-channels {
  inet 127.0.0.1 port 53 allow { 127.0.0.1; };
};

重新啟動named

service named restart
  • 在Prometheus的yml文件中添加如下job,重新啟動Prometheus即可
  - job_name: dns-master
    static_configs:
      - targets: ['10.85.6.66:9119']
        labels:
          alias: dns-master

在Prometheus的targets中可以看到新加的內容

可以通過“curl http://10.85.6.66:9119/metrics”來獲取bind_exporter支持的metrics以及方法,最常用的方法為“bind_up”,用於查看一個bind服務是否啟動,值1表示啟動成功

 

參考:

https://grafana.com/dashboards/1666

https://computingforgeeks.com/how-to-monitor-bind-dns-server-with-prometheus-and-grafana/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM