blackbox_exporter介紹

Blackbox Exporter是Prometheus社區提供的官方黑盒監控解決方案,其容許用戶經過:HTTP、HTTPS、DNS、TCP以及ICMP的方式對網絡進行探測。linux

一、安裝部署json

cd /usr/loacl
tar -xvf blackbox_exporter-0.14.0.linux-amd64.tar.gz
ln -s /usr/local/blackbox_exporter-0.14.0.linux-amd64  /usr/local/blackbox_exporter
cd /usr/local/blackbox_exporter;mkdir bin conf
mv blackbox_exporter ./bin
mv blackbox.yml ./conf

二、配置bash

modules:
  http_2xx_check:
    prober: http
    timeout: 5s
    http:
      valid_status_codes: []
      method: GET
  icmp_check:
    prober: icmp
    timeout: 5s
    icmp:
      preferred_ip_protocol: "ip4"
  dns_examplecom_check:
    prober: dns
    dns:
      preferred_ip_protocol: "ip4"
      query_name: "www.cnblogs.com"

三、啓動網絡

nohup /usr/local/blackbox_exporter/bin/blackbox_exporter --config.file=/usr/local/blackbox_exporter/conf/blackbox.yml > blackbox_exporter.out 2>&1 &

四、prometheus.yml 配置curl

  - job_name: 'http_probe'
    metrics_path: /probe
    params:
      module: [http_2xx_check]
    file_sd_configs:
      - files:
        - 'targets/probes/*.json'
        refresh_interval: 5m
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.31.82:9115

備註:url

  • 第一個relabel經過將__address__標籤(當前目標地址)寫入__param_target標籤來建立一個參數。
  • 第二個relabel將__param_target標籤寫爲實例標籤。
  • 最後一個使用咱們的主機名(和端口)從新標記__address__標籤。

五、targets/probes/probes.json配置spa

[{
  "targets": [
    "http://www.cnblogs.com"
  ]
}]

六、重載code

curl -X POST http://127.0.0.1:9090/-/reload

相關文章
相關標籤/搜索