我们正在使用 Prometheus Blackbox Exporter(blackbox_exporter,版本 0.19.0)来检查 HTTP 端点。
现在我们需要使用fail_if_body_matches_regexp
.
当 html 正文中存在某个单词时,检查应该失败。
为此,我们创建了以下 http prob 配置:
Module configuration:
prober: http
timeout: 5s
http:
valid_http_versions:
- HTTP/1.1
- HTTP/2
- HTTP/2.0
preferred_ip_protocol: ip4
ip_protocol_fallback: true
fail_if_body_matches_regexp:
- The page is temporarily unavailable
follow_redirects: true
tcp:
ip_protocol_fallback: true
icmp:
ip_protocol_fallback: true
dns:
ip_protocol_fallback: true
不幸的是,检查没有按预期工作。即使网站包含The page is temporarily unavailable
在 html 正文中,检查仍然成功。
Logs for the probe:
ts=2022-02-17T09:46:31.403831228Z caller=main.go:320 module=http_2xx target=https://site.local level=info msg="Beginning probe" probe=http timeout_seconds=5
ts=2022-02-17T09:46:31.403959629Z caller=http.go:335 module=http_2xx target=https://site.local level=info msg="Resolving target address" ip_protocol=ip4
ts=2022-02-17T09:46:31.500911613Z caller=http.go:335 module=http_2xx target=https://site.local level=info msg="Resolved target address" ip=XXX.XXX.XXX.XXX
ts=2022-02-17T09:46:31.501017313Z caller=client.go:251 module=http_2xx target=https://site.local level=info msg="Making HTTP request" url=https://XXX.XXX.XXX.XXX host=site.local
ts=2022-02-17T09:46:31.614236162Z caller=main.go:130 module=http_2xx target=https://site.local level=info msg="Received HTTP response" status_code=200
Metrics that would have been returned:
# 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 0
要检查网站是否在 Prometheus Blackbox Exporter 中正确加载,我想检查测试期间收到的 html 正文。有谁知道这是否可能并且可能有一些进一步的调试提示?