跳转到内容

HTTP 可用性拨测(`http_probe`)

inputs.http_probe 提供轻量零依赖的 HTTP/HTTPS 端点可用性与分段耗时拨测,支持在同一探针中配置多个独立探测目标。

inputs:
http_probe:
- id: api_prod
url: https://api.example.com/health
method: GET
interval: 10s
timeout: 5s
expected_status: 200
headers:
Authorization: "Bearer xxx"
follow_redirects: false
insecure_skip_verify: false
字段 类型 默认值 说明
id string 必填 拨测实例 ID,指标将自动注册为 http_probe.<id>.*
url string 必填 目标探测 URL
method string GET HTTP 请求方法
interval duration global.interval 拨测频率
timeout duration 5s 单次请求超时时间
expected_status int 200 期望 HTTP 状态码
headers map {} 自定义请求头
follow_redirects bool false 是否跟随 3xx 重定向
insecure_skip_verify bool false 是否跳过 TLS 证书校验

每个实例 <id> 自动注册以下 6 个指标:

指标名 单位 说明
http_probe.<id>.up 0/1 探测成功且状态码等于 expected_status 时为 1,否则为 0
http_probe.<id>.status_code - HTTP 响应状态码(网络或超时失败时为 0)
http_probe.<id>.latency_ms ms 完整请求耗时
http_probe.<id>.dns_ms ms DNS 解析耗时
http_probe.<id>.tls_ms ms TLS 握手耗时
http_probe.<id>.ttfb_ms ms 首字节响应时间(Time To First Byte)

alerts:
# 仅拍摄 http_probe/api_prod 的拨测曲线,不夹带无关主机数据
- id: api_prod_down
severity: critical
for: 10s
expr: 'last("http_probe.api_prod.up") == 0'
# 接口变慢时,顺带通过 attach 拍下本机 host/default 现场
- id: api_prod_slow
severity: warning
for: 15s
expr: 'avg("http_probe.api_prod.latency_ms", 60) > 1500'
attach: ["host/default"]