0

我想在blackbox_exporter中使用“fail_if_body_not_matches_regexp”来检测一个HTTP接口是否返回了一个字符串(这个接口是GET类型的url),但是blackbox_exporter页面的结果总是401。顺便说一下,我可以正常访问这个通过浏览器进行界面并获取结果

我想检测rabbitMQ的脑裂,但是rabbitmq_exporter无法检测到脑裂。所以我在blackbox_exporter中使用HTTP探针来做正则表达式匹配接口的结果。但是当我配置一切都完成了。我访问url“ http://10.201.5.197:9115/probe?module=http_2rabbitmq_brainSplit&target=10.201.7.209%3A15672%2Fapi%2Fnodes ”,黑框一直显示401,如下图

# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds
# TYPE probe_dns_lookup_time_seconds gauge
probe_dns_lookup_time_seconds 3.6954e-05
# HELP probe_duration_seconds Returns how long the probe took to complete in seconds
# TYPE probe_duration_seconds gauge
probe_duration_seconds 0.002106961
# HELP probe_failed_due_to_regex Indicates if probe failed due to regex
# TYPE probe_failed_due_to_regex gauge
probe_failed_due_to_regex 1
# HELP probe_http_content_length Length of http content response
# TYPE probe_http_content_length gauge
probe_http_content_length 54
# HELP probe_http_duration_seconds Duration of http request by phase, summed over all redirects
# TYPE probe_http_duration_seconds gauge
probe_http_duration_seconds{phase="connect"} 0.000388833
probe_http_duration_seconds{phase="processing"} 0.001160027
probe_http_duration_seconds{phase="resolve"} 3.6954e-05
probe_http_duration_seconds{phase="tls"} 0
probe_http_duration_seconds{phase="transfer"} 0.000159596
# HELP probe_http_redirects The number of redirects
# TYPE probe_http_redirects gauge
probe_http_redirects 0
# HELP probe_http_ssl Indicates if SSL was used for the final redirect
# TYPE probe_http_ssl gauge
probe_http_ssl 0
# HELP probe_http_status_code Response HTTP status code
# TYPE probe_http_status_code gauge
probe_http_status_code 401
# HELP probe_http_version Returns the version of HTTP of the probe response
# TYPE probe_http_version gauge
probe_http_version 1.1
# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6
# TYPE probe_ip_protocol gauge
probe_ip_protocol 4
# HELP probe_success Displays whether or not the probe was a success
# TYPE probe_success gauge
probe_success 0

我的普罗米修斯 config.yaml:

  - job_name: 'rabbitma_brainSplit'
    metrics_path: /probe
    basic_auth:
      username: admin
      password: GSS1duS1Zdda
    params:
      module: [http_2rabbitmq_brainSplit]  
    static_configs:
      - targets:
        - 10.201.7.209:15672/api/nodes   
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.201.5.197:9115

我的 black_exporter config.yml:

modules:
  http_2rabbitmq_brainSplit:
    prober: http
    timeout: 10s
    http:
      valid_http_versions: ["HTTP/1.1", "HTTP/2"]
      valid_status_codes: []  
      method: GET
      headers:
        Accept-Language: zh-CN,zh;q=0.9
      no_follow_redirects: false
      fail_if_ssl: false
      fail_if_not_ssl: false
      fail_if_body_not_matches_regexp:
      - '\"partitions\":\[\s+\]'

我期望 fail_if_body_not_matches_regexp 的正则表达式匹配结果。我配置错了吗?

4

0 回答 0