首页 > 其他分享 >Prometheus基于blackbox_exporter监控

Prometheus基于blackbox_exporter监控

时间:2023-01-08 21:44:25浏览次数:71  
标签:exporter blackbox prometheus tcp Prometheus 监控 prober

blackbox_exporter 监控组件

  blackbox_exporter 是 Prometheus 官方提供的一个 exporter,可以监控 HTTP、 HTTPS,、DNS、 TCP 、ICMP 等目标实例,从而实现对被监控节点进行监控 和数据采集。promethes调用blackbox_exporter去访问目标监控服务器,实现指标的采集

  prometheus blackbox_exporter下载地址:Download | Prometheus

  HTTP/HTPPS:URL/API 可用性检测

  TCP:端口监听检测

  ICMP:主机存活检测

  DNS:域名解析

 

  下载和部署blackbox_exporter

  https://github.com/prometheus/blackbox_exporter

root@prometheus:~# tar xf blackbox_exporter-0.22.0.linux-amd64.tar.gz  -C /usr/local/
root@prometheus:~# cd /usr/local/
root@prometheus:/usr/local# ln -s blackbox_exporter-0.22.0.linux-amd64 blackbox_exporter

 

  blackbox的配置文件中只是制定了监控的类型模块,真正监控具体的数据实在prometheus-server上配置

root@prometheus:/usr/local/blackbox_exporter# cat blackbox.yml 
modules:
  http_2xx:
    prober: http
  http_post_2xx:
    prober: http
    http:
      method: POST
  tcp_connect:
    prober: tcp
  pop3s_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^+OK"
      tls: true
      tls_config:
        insecure_skip_verify: false
  grpc:
    prober: grpc
    grpc:
      tls: true
      preferred_ip_protocol: "ip4"
  grpc_plain:
    prober: grpc
    grpc:
      tls: false
      service: "service1"
  ssh_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^SSH-2.0-"
      - send: "SSH-2.0-blackbox-ssh-check"
  irc_banner:
    prober: tcp
    tcp:
      query_response:
      - send: "NICK prober"
      - send: "USER prober prober prober :prober"
      - expect: "PING :([^ ]+)"
        send: "PONG ${1}"
      - expect: "^:[^ ]+ 001"
  icmp:
    prober: icmp
  icmp_ttl5:
    prober: icmp
    timeout: 5s
    icmp:
      ttl: 5

 

  创建blackbox_exporter service启动文件,默认监听9115端口

vim /etc/systemd/system/blackbox-exporter.service
[Unit]
Description=Prometheus Blackbox Exporter
After=network.target


[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/blackbox_exporter/blackbox_exporter \
  --config.file=/usr/local/blackbox_exporter/blackbox.yml \
  --web.listen-address=:9115 

Restart=on-failure 

[Install] 
WantedBy=multi-user.target 

 

  启动blackbox_exporter

systemctl daemon-reload && systemctl enable blackbox-exporter.service && systemctl start blackbox-exporter.service

  验证web界面 IP:9115

 

  访问URI: /metrics

 

  blackbox exporter 实现 URL 监控

 

标签:exporter,blackbox,prometheus,tcp,Prometheus,监控,prober
From: https://www.cnblogs.com/punchlinux/p/17035311.html

相关文章