HTTP API
REST API 在代理运行时位于 http://127.0.0.1:3000/api/v1/。
流量
GET /api/v1/flows
搜索和分页捕获的流量。
GET /api/v1/flows?limit=10&offset=0&filter=method:GET
查询参数:
limit— 返回的流量数量(默认:50)offset— 分页偏移filter— 过滤表达式(例如method:GET host:*.example.com)
{
"flows": [
{
"id": "fld_01HX5K9P3Q8Y2Z7",
"timestamp": "2024-01-15T10:23:45.123Z",
"method": "GET",
"url": "https://api.example.com/users",
"host": "api.example.com",
"path": "/users",
"status": 200,
"duration_ms": 42,
"size": 1847
}
],
"pagination": {
"total": 12847,
"returned": 10,
"offset": 0
}
} GET /api/v1/flows/:id
获取详细的流量信息,包括请求头和请求体。
GET /api/v1/flows/fld_01HX5K9P3Q8Y2Z7
规则
GET /api/v1/rules
列出所有拦截规则。
GET /api/v1/rules
PUT /api/v1/rules
创建或更新规则。
PUT /api/v1/rules
{
"id": "rul_01HX5K9P3Q8Y2Z7",
"name": "Log API requests",
"priority": 100,
"filter": {
"method": "GET",
"host": "*.example.com",
"path": "/api/*"
},
"action": {
"type": "log"
},
"enabled": true
} DELETE /api/v1/rules/:id
删除规则。
DELETE /api/v1/rules/rul_01HX5K9P3Q8Y2Z7
拦截
POST /api/v1/intercepts
创建拦截断点。
POST /api/v1/intercepts
{
"filter": {
"method": "POST",
"host": "api.example.com"
},
"pause_at": "request"
} POST /api/v1/intercepts/resolve
解决待处理的拦截(继续、修改或丢弃)。
{
"flow_id": "fld_01HX5K9P3Q8Y2Z7",
"action": "resume",
"modifications": {}
} 事件
GET /api/v1/events
用于实时更新的 Server-Sent Events 流。
GET /api/v1/events
事件类型:flow::new、flow::update、intercept::pending、rule::matched
指标
GET /api/v1/metrics
JSON 指标快照。
GET /api/v1/metrics/prometheus
Prometheus 文本格式指标。
# HELP relay_core_flows_total Total number of flows captured
# TYPE relay_core_flows_total counter
relay_core_flows_total 12847
# HELP relay_core_request_duration_ms Request duration in milliseconds
# TYPE relay_core_request_duration_ms histogram
relay_core_request_duration_ms_bucket{le="1"} 10023
relay_core_request_duration_ms_bucket{le="5"} 12500
relay_core_request_duration_ms_bucket{le="10"} 12800
relay_core_request_duration_ms_bucket{le="+Inf"} 12847 审计
GET /api/v1/audit
查询控制平面变更审计日志。
GET /api/v1/audit?since=2024-01-15T00:00:00Z