查询网站访问日志
/v1/monitor/site/access-log查询 Elasticsearch 中的网站 HTTP 访问日志,按时间倒序返回。接口要求登录。普通用户固定只能查询自己的 uid 和名下域名;管理员可通过 uid 查询指定用户,或不传 uid 查询全部用户。start 与 end 必填,时区固定按 +08:00 解释。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
start | query | string | 必填 | 查询起始时间(含),格式 完整参数定义 |
end | query | string | 必填 | 查询结束时间(不含),格式 完整参数定义 |
host | query | string | 可选 | 空格分隔的网站域名。普通用户的每个域名必须属于自己;通配符网站可匹配对应子域名。 完整参数定义 |
server_port | query | string | 可选 | 源站服务端口,必须为合法端口。 完整参数定义 |
addr | query | string | 可选 | 客户端 IP 精确筛选,必须为合法 IP。 完整参数定义 |
uid | query | integer | 可选 | 仅管理员有效:用户 ID 精确筛选。普通用户传入时被忽略。管理员未传时不添加 uid 筛选。 完整参数定义 |
req_uri | query | string | 可选 | 请求 URI,必须以 完整参数定义 |
uri_match_type | query | string | 可选 | URI 匹配方式: 完整参数定义 |
status | query | string | 可选 | 三位 HTTP 状态码精确筛选。 完整参数定义 |
node_id | query | string | 可选 | 节点 ID(日志字段 nid),必须为数字。 完整参数定义 |
cache_status | query | string | 可选 | 缓存状态精确筛选。 完整参数定义 |
method | query | string | 可选 | HTTP 方法精确筛选,仅允许 1 至 10 个英文字母。 完整参数定义 |
tls_fp | query | string | 可选 | JA4 TLS 指纹,必须为 36 个字母、数字或下划线。 完整参数定义 |
country | query | string | 可选 | 国家名称精确筛选。 完整参数定义 |
province | query | string | 可选 | 省份名称精确筛选。 完整参数定义 |
city | query | string | 可选 | 城市名称精确筛选。 完整参数定义 |
isp | query | string | 可选 | 运营商名称精确筛选。 完整参数定义 |
referer | query | string | 可选 | Referer 精确筛选。 完整参数定义 |
page | query | integer | 可选 | 页码,默认 1。服务端最多查询前 1000 条,超过范围时会调整页码。 完整参数定义 |
limit | query | integer | 可选 | 每页条数,默认 10;服务端会将超过 100 的值压缩为 100。 完整参数定义 |
get_count | query | string | 可选 | 任意非空值均启用仅计数模式;启用时不返回日志数组。 完整参数定义 |
响应
HTTP 200
成功、筛选参数错误和认证/网站归属错误均返回 HTTP 200。普通查询的总数由日志库返回,查询体设置 track_total_hits=1000。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | integer | 必填 | 仅统计匹配数量时成功状态固定为 0。 约束 / 默认值 / 示例 |
data | integer | 必填 | 仅 get_count 非空时返回的匹配日志数量。 约束 / 默认值 / 示例 |
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 访问日志列表查询成功时固定为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count | integer | 必填 | 当前筛选条件下日志库返回的匹配总数。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | array <object> | 必填 | 当前页日志,按 time 倒序。 展开字段结构当前页日志,按 time 倒序。 数组元素 · object
|
oneOf · 3 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | 时间、域名归属、IP、状态码、缓存状态、URI、端口、节点、方法、URI 匹配方式、TLS 指纹或认证失败的业务错误码。 约束 / 默认值 / 示例 |
msg | string | 必填 | 访问日志查询参数校验或认证失败的具体原因。 |
data | string | 必填 | 发生业务错误时固定返回空字符串。 约束 / 默认值 / 示例 |
完整 Schema
{
"oneOf": [
{
"type": "object",
"required": [
"code",
"data"
],
"properties": {
"code": {
"type": "integer",
"enum": [
0
],
"description": "仅统计匹配数量时成功状态固定为 0。"
},
"data": {
"type": "integer",
"minimum": 0,
"description": "仅 get_count 非空时返回的匹配日志数量。"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"code",
"count",
"data"
],
"properties": {
"code": {
"type": "integer",
"enum": [
0
],
"description": "访问日志列表查询成功时固定为 0。"
},
"count": {
"type": "integer",
"minimum": 0,
"description": "当前筛选条件下日志库返回的匹配总数。"
},
"data": {
"type": "array",
"description": "当前页日志,按 time 倒序。",
"items": {
"type": "object",
"required": [
"_id",
"tls_fp",
"host2",
"country",
"province",
"city",
"nid",
"status",
"protocol",
"addr",
"bytes_sent",
"cache_status",
"up_resp_time",
"host",
"server_port",
"referer",
"user_agent",
"content_type",
"time",
"req_uri",
"up_recv",
"method",
"timestamp",
"sip",
"l1_cache_status",
"l2_cache_status",
"l2_ip",
"lat",
"lng",
"isp"
],
"properties": {
"_id": {
"type": "string",
"description": "日志文档 ID。"
},
"tls_fp": {
"type": "string",
"description": "TLS 指纹,缺失时为空字符串。"
},
"host2": {
"type": "string",
"description": "附加 Host 字段,缺失时为空字符串。"
},
"country": {
"type": "string",
"description": "国家,缺失时为空字符串。"
},
"province": {
"type": "string",
"description": "省份,缺失时为空字符串。"
},
"city": {
"type": "string",
"description": "城市,缺失时为空字符串。"
},
"nid": {
"type": "string",
"description": "节点 ID。"
},
"status": {
"type": "string",
"description": "HTTP 状态码。"
},
"protocol": {
"type": "string",
"description": "请求协议。"
},
"addr": {
"type": "string",
"description": "客户端 IP。"
},
"bytes_sent": {
"type": "integer",
"description": "响应发送字节数。"
},
"cache_status": {
"type": "string",
"description": "缓存状态。"
},
"up_resp_time": {
"description": "上游响应耗时,保持日志库原始类型。"
},
"host": {
"type": "string",
"description": "请求 Host。"
},
"server_port": {
"description": "源站端口;日志缺失时为空字符串。"
},
"referer": {
"type": "string",
"description": "Referer。"
},
"user_agent": {
"type": "string",
"description": "User-Agent。"
},
"content_type": {
"type": "string",
"description": "响应 Content-Type。"
},
"time": {
"type": "string",
"description": "日志时间字段。"
},
"req_uri": {
"type": "string",
"description": "请求 URI。"
},
"up_recv": {
"description": "上游接收字节数,保持日志库原始类型。"
},
"method": {
"type": "string",
"description": "HTTP 方法。"
},
"timestamp": {
"description": "Elasticsearch sort 时间戳,保持原始类型。"
},
"sip": {
"type": "string",
"description": "源站 IP,缺失时为空字符串。"
},
"l1_cache_status": {
"type": "string",
"description": "一级缓存状态,缺失时为空字符串。"
},
"l2_cache_status": {
"type": "string",
"description": "二级缓存状态,缺失时为空字符串。"
},
"l2_ip": {
"type": "string",
"description": "二级节点 IP,缺失时为空字符串。"
},
"lat": {
"description": "纬度,缺失时为空字符串。"
},
"lng": {
"description": "经度,缺失时为空字符串。"
},
"isp": {
"type": "string",
"description": "运营商,缺失时为空字符串。"
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "string",
"enum": [
"access_log-1",
"access_log-2",
"access_log-3",
"access_log-4",
"access_log-5",
"access_log-6",
"access_log-7",
"access_log-9",
"access_log-10",
"access_log-11",
"access_log-12",
"access_log-13",
"login_required"
],
"description": "时间、域名归属、IP、状态码、缓存状态、URI、端口、节点、方法、URI 匹配方式、TLS 指纹或认证失败的业务错误码。"
},
"msg": {
"type": "string",
"description": "访问日志查询参数校验或认证失败的具体原因。"
},
"data": {
"type": "string",
"enum": [
""
],
"description": "发生业务错误时固定返回空字符串。"
}
},
"additionalProperties": false
}
]
}示例
{
"code": 0,
"count": 1,
"data": [
{
"_id": "REDACTED_LOG_ID",
"tls_fp": "",
"host2": "",
"country": "",
"province": "",
"city": "",
"nid": "1001",
"status": "200",
"protocol": "HTTP/2.0",
"addr": "192.0.2.10",
"bytes_sent": 1024,
"cache_status": "HIT",
"up_resp_time": 0.01,
"host": "www.example.invalid",
"server_port": "443",
"referer": "",
"user_agent": "curl/8",
"content_type": "text/html",
"time": "2026-01-01 00:00:01",
"req_uri": "/",
"up_recv": 0,
"method": "GET",
"timestamp": 1767225601000,
"sip": "198.51.100.1",
"l1_cache_status": "HIT",
"l2_cache_status": "",
"l2_ip": "",
"lat": "",
"lng": "",
"isp": ""
}
]
}日志列表
{
"code": 0,
"count": 1,
"data": [
{
"_id": "REDACTED_LOG_ID",
"tls_fp": "",
"host2": "",
"country": "",
"province": "",
"city": "",
"nid": "1001",
"status": "200",
"protocol": "HTTP/2.0",
"addr": "192.0.2.10",
"bytes_sent": 1024,
"cache_status": "HIT",
"up_resp_time": 0.01,
"host": "www.example.invalid",
"server_port": "443",
"referer": "",
"user_agent": "curl/8",
"content_type": "text/html",
"time": "2026-01-01 00:00:01",
"req_uri": "/",
"up_recv": 0,
"method": "GET",
"timestamp": 1767225601000,
"sip": "198.51.100.1",
"l1_cache_status": "HIT",
"l2_cache_status": "",
"l2_ip": "",
"lat": "",
"lng": "",
"isp": ""
}
]
}仅获取数量
{
"code": 0,
"data": 42
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/monitor/site/access-log" \
--header "access-token: YOUR_ACCESS_TOKEN"