使用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中可以看到新加的内容

使用Prometheus监控bind9的DNS服务

可以通过“curl http://10.85.6.66:9119/metrics”来获取bind_exporter支持的metrics以及方法,最常用的方法为“bind_up”,用于查看一个bind服务是否启动,值1表示启动成功使用Prometheus监控bind9的DNS服务

 

参考:

https://grafana.com/dashboards/1666

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

 

给TA打赏
共{{data.count}}人
人已打赏
随笔日记

2019年精品俄罗斯VPS推荐,容易买、好沟通的俄罗斯VPS商家推荐

2020-11-9 5:22:29

随笔日记

【译】3D打印:介绍

2020-11-9 5:22:31

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索