Prometheus - blackbox

2021-10-09

blackbox.yaml

modules:
  http_2xx:
    prober: http
    http:
      preferred_ip_protocol: "ip4"
  http_post_2xx:
    prober: http
    http:
      preferred_ip_protocol: "ip4"
      method: POST
  http_2xx_proxy_ucloud:
    prober: http
    http:
      preferred_ip_protocol: "ip4"
      proxy_url: http://proxy.xx.com:23908
  tcp_connect:
    prober: tcp
  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

prometheus.yaml

- job_name: 'check_http_2xx_appId'
  scrape_interval: 15s
  metrics_path: /probe
  params:
    module: [http_2xx]
  static_configs:
  consul_sd_configs:
  - server: consul-server.monitoring.svc.cluster.local:8500
    tag_separator: ','
    services:
    - http_2xx_appId
  relabel_configs:
    - source_labels: ['__meta_consul_service_port']
      target_label: appid
    - source_labels: ['__meta_consul_service_address']
      target_label: __param_target
    - source_labels: ['__meta_consul_service_address']
      target_label: target
    - target_label: __address__
      replacement: blackbox.monitoring.svc.cluster.local:9115