Prometheus之blackbox exporter实现URL监控

一 URL监控配置

1.1 修改Prometheus Server配置文件

root@prometheus-01:~# cat /usr/local/prometheus/prometheus.yml 

#网站监控
  - job_name: 'http_status'
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:                  # 宿主机或docker不开启IPV6,则不支持IPV6解析。
        - http://www.baidu.com    # Target to probe with http.
        - https://www.xiaomi.com   # Target to probe with https.
        - http://192.168.174.120:9090 # Target to probe with http on port 8080.
        labels:
          instance: http_status
          group: web
    relabel_configs:
      - source_labels: [__address__]  #relabel 通过将__address__(当前目标地址)写入__param_target标签来创建一个label
        target_label: __param_target #监控目标 www.baidu.com,作为__address__的value
      - source_labels: [__param_target] #监控目标
        target_label: url #将监控目标与URL创建一个label
      - 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验证数据

Prometheus之blackbox exporter实现URL监控

三 blackbox exporter验证数据

 Prometheus之blackbox exporter实现URL监控

 

上一篇:SpringCloud-Stream实战入门(二,缓存架构技术


下一篇:Prometheus之grafana可视化