我一直在努力理解为什么一些 HTTP 端点会为“probe_success”和“probe_http_status_code”返回“0”,同时完全能够通过 curl 获得“有效”响应。
例子:curl -s "localhost:9115/probe?target=http://linux.org&module=http_2xx" | grep -v '^#'
输出:
probe_dns_lookup_time_seconds 0.003712821
probe_duration_seconds 0.212811871
probe_failed_due_to_regex 0
probe_http_content_length 0
probe_http_duration_seconds{phase="connect"} 0.002263513
probe_http_duration_seconds{phase="processing"} 0.196389853
probe_http_duration_seconds{phase="resolve"} 0.006723945
probe_http_duration_seconds{phase="tls"} 0
probe_http_duration_seconds{phase="transfer"} 2.6001e-05
probe_http_redirects 1
probe_http_ssl 0
probe_http_status_code 0
probe_http_version 0
probe_ip_protocol 4
probe_success 0
这是工作定义:
- job_name: 'blackbox'
scrape_interval: 30s
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- http://linux.org
relabel_configs:
- source_labels: [__address__]
regex: '(.*)(:80)?'
target_label: __param_target
- source_labels: [__param_target]
regex: '(.*)'
target_label: instance
replacement: '${1}'
- source_labels: []
regex: '.*'
target_label: __address__
replacement: 'blackbox:9115'
和模块定义:
modules:
http_2xx:
prober: http
timeout: 15s
http:
valid_status_codes: []
method: GET