ps-5 blackbox

blackbox.yaml

modules:
  http_2xx:
    prober: http
    timeout: 5s
    http:
      preferred_ip_protocol: ip4
      #header、token配置
      headers:
        Host: "probe.xxx.com"
        Cache-Control: no-cache
      bearer_token: '<token>'
  tcp_connect:
    prober: tcp
    timeout: 5s
    tcp:
      preferred_ip_protocol: ip4
  icmp:
    prober: icmp
    timeout: 5s
    icmp:
      preferred_ip_protocol: ip4
  http_2xx_home:
    prober: http
    timeout: 5s
    http:
      method: GET
      fail_if_body_not_matches_regexp:
      - "OK"
      fail_if_not_ssl: false
      preferred_ip_protocol: ip4

prometheus.yaml配置

global:
  scrape_interval:     15s 
  evaluation_interval: 15s

alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - alertmanager:9093

rule_files:
  - /etc/prometheus/rules/*.rules

scrape_configs:
  - job_name: "blackbox-dev"
    metrics_path: /probe
    scheme: http
    params:
      module: [http_2xx]
    file_sd_configs:
      - files:
        - targets/dev-targets.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox_exporter:9115
  - job_name: "blackbox-pre"
    metrics_path: /probe
    scheme: http
    params:
      module: [http_2xx]
    file_sd_configs:
      - files:
        - targets/pre-targets.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox_exporter:9115
  - job_name: "blackbox-pro"
    metrics_path: /probe
    scheme: http
    params:
      module: [http_2xx]
    file_sd_configs:
      - files:
        - targets/pro-targets.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox_exporter:9115

 ...

posted @ 2025-06-05 15:06  冰冷的火  阅读(21)  评论(0)    收藏  举报