Prometheus之blackbox exporter实现端口监控


一 端口监控配置

1.1 修改Prometheus Server配置文件

root@prometheus-01:~# cat /usr/local/prometheus/prometheus.yml 
#端口监控
  - job_name: 'port_status'
    metrics_path: /probe
    params:
      module: [tcp_connect] 
    static_configs:
      - targets:
        - 192.168.174.200:3000    
        - 192.168.174.103:9090 
        labels:
          instance: port_status
          group: port
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: ip
      - target_label: __address__
        replacement: 192.168.174.104:9115  # The blackbox exporter's real hostname:port.

1.2 检查文件

root@prometheus-01:~# /usr/local/prometheus/promtool check config /usr/local/prometheus/prometheus.yml 
Checking /usr/local/prometheus/prometheus.yml
  SUCCESS: 1 rule files found

Checking /usr/local/prometheus/alert_rules/instance_up.yaml
  SUCCESS: 1 rules found

1.3 重启Prometheus服务

root@prometheus-01:~# systemctl restart prometheus

二 Prometheus验证数据

三 blackbox exporter验证数据