Skip to main content

遥测与健康

NexaLayer 不只返回代理地址,还接收自动化任务的执行结果。上报事件越准确,健康评分和轮换建议越有用。

上报事件

curl -X POST "https://api.nexalayer.net/v1/sessions/$SID/report-event" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $NEXALAYER_API_KEY" \
  -d '{
    "event_type": "http_error",
    "status_code": 403,
    "target_host": "example.com",
    "latency_ms": 1800
  }'

event_type

类型含义
success请求或页面任务成功
http_errorHTTP 错误
captcha遇到验证码
timeout请求或页面加载超时
block明确被拦截或封禁
rate_limit429 或频控
custom业务自定义事件

查询健康

curl "https://api.nexalayer.net/v1/sessions/$SID/health" \
  -H "X-API-Key: $NEXALAYER_API_KEY"
响应包含:
字段说明
health_score0-100 健康分
risk_levellowmediumhigh
success_rate成功率
consecutive_failures连续失败次数
recommendationokconsider_rotaterotate_nowpause
timeoutcaptchablock 不是中性噪声,它们应该进入健康判断。