promethus -Blackbox-exporter端口监控实现网络探测

关于Blackbox-exporter

-Blackbox Exporter是Prometheus社区提供的官方黑盒监控解决方案,其允许用户通过:HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测。
-黑盒监控即以用户的身份测试服务的外部可见性,常见的黑盒监控包括HTTP探针、TCP探针等用于检测站点或者服务的可访问性,以及访问效率等。
-黑盒监控相较于白盒监控最大的不同在于黑盒监控是以故障为导向当故障发-生时,黑盒监控能快速发现故障,而白盒监控则侧重于主动发现或者预测潜在的问题。一个完善的监控目标是要能够从白盒的角度发现潜在问题,能够在黑盒的角度快速发现已经发生的问题。

实际应用

部署Blackbox-exporter

1.根据镜像进行部署

blackbox-exporter官方dockerhub地址
blackbox-exporter官方github地址

2.部署流程(docker-compose进行部署)
  ##镜像拉取
  docker pull prom/blackbox-exporter
  ##docker部署
  docker run --rm -d -p 9115:9115 --name blackbox_exporter -v `pwd`:/config prom/blackbox-exporter:master --config.file=/config/blackbox.yml
## docker-compose.yml
version: '2'
services:
blackbox_exporter:
  image: prom/blackbox-exporter
  container_name: blackbox_exporter
  restart: always
  dns_search: .
  networks:
    - nets
  volumes:
    - ./blackbox_exporter/blackbox.yml:/etc/blackbox_exporter/config.yml
  ports:
    - 9115:9115
  tty: true
networks:
nets:
  external: false
## blackbox_exporter/blackbox.yml
modules:
http_2xx:
  prober: http
  timeout: 20s
  http:
    preferred_ip_protocol: "ip4"
http_post_2xx_query:
  prober: http
  timeout: 20s
  http:
    preferred_ip_protocol: "ip4" ##使用ipv4
    method: POST
    headers:
      Content-Type: application/json ##header头
    body: '{"hmac":"","params":{"publicFundsKeyWords":"xxx"}}' ##传参
tls_connect_tls:
  prober: tcp
  timeout: 5s
  tcp:
    tls: true
tcp_connect:
  prober: tcp
  timeout: 5s
 #
pop3s_banner:
  prober: tcp
  tcp:
    query_response:
    - expect: "^+OK"
    tls: true
    tls_config:
      insecure_skip_verify: false
ssh_banner:
  prober: tcp
  tcp:
    query_response:
    - expect: "^SSH-2.0-"
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
  timeout: 20s
3.promethus配置blackbox-exporter
## promethus.yml
  - job_name: 'port_status_name'
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets: ['ip:端口']
        labels:
          instance: 'port_status_name'
          group: 'tcp'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporterIP地址:9115

image.png

4.grafana配置

导入模板
此模板为9965号模板,数据源选择Prometheus 模板下载地址 https://grafana.com/grafana/d...
image
可参考:Blackbox_exporter黑盒监测+promethus+grafana配置

5.附录

Prometheus 实战
Blackbox_exporter黑盒监测+promethus+grafana配置
部署Black Exporter
网络探测:Blackbox Exporter+应用场景分析
Prometheus 监控之 Blackbox_exporter黑盒监测

你可能感兴趣的:(promethus -Blackbox-exporter端口监控实现网络探测)