itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询网站访问日志

GET/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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
startquerystring必填

查询起始时间(含),格式 YYYY-MM-DD HH:mm:ss。

完整参数定义
{
  "name": "start",
  "in": "query",
  "required": true,
  "description": "查询起始时间(含),格式 `YYYY-MM-DD HH:mm:ss`。",
  "schema": {
    "type": "string",
    "example": "2026-01-01 00:00:00"
  }
}
endquerystring必填

查询结束时间(不含),格式 YYYY-MM-DD HH:mm:ss。

完整参数定义
{
  "name": "end",
  "in": "query",
  "required": true,
  "description": "查询结束时间(不含),格式 `YYYY-MM-DD HH:mm:ss`。",
  "schema": {
    "type": "string",
    "example": "2026-01-01 01:00:00"
  }
}
hostquerystring可选

空格分隔的网站域名。普通用户的每个域名必须属于自己;通配符网站可匹配对应子域名。

完整参数定义
{
  "name": "host",
  "in": "query",
  "required": false,
  "description": "空格分隔的网站域名。普通用户的每个域名必须属于自己;通配符网站可匹配对应子域名。",
  "schema": {
    "type": "string",
    "example": "www.example.invalid api.example.invalid"
  }
}
server_portquerystring可选

源站服务端口,必须为合法端口。

完整参数定义
{
  "name": "server_port",
  "in": "query",
  "required": false,
  "description": "源站服务端口,必须为合法端口。",
  "schema": {
    "type": "string",
    "example": "443"
  }
}
addrquerystring可选

客户端 IP 精确筛选,必须为合法 IP。

完整参数定义
{
  "name": "addr",
  "in": "query",
  "required": false,
  "description": "客户端 IP 精确筛选,必须为合法 IP。",
  "schema": {
    "type": "string",
    "example": "192.0.2.10"
  }
}
uidqueryinteger可选

仅管理员有效:用户 ID 精确筛选。普通用户传入时被忽略。管理员未传时不添加 uid 筛选。

完整参数定义
{
  "name": "uid",
  "in": "query",
  "required": false,
  "description": "仅管理员有效:用户 ID 精确筛选。普通用户传入时被忽略。管理员未传时不添加 uid 筛选。",
  "schema": {
    "type": "integer",
    "example": 12
  }
}
req_uriquerystring可选

请求 URI,必须以 / 开头。匹配方式由 uri_match_type 决定。

完整参数定义
{
  "name": "req_uri",
  "in": "query",
  "required": false,
  "description": "请求 URI,必须以 `/` 开头。匹配方式由 uri_match_type 决定。",
  "schema": {
    "type": "string",
    "example": "/assets/app.js"
  }
}
uri_match_typequerystring可选

URI 匹配方式:exact 精确匹配(默认);prefix 以前缀匹配并将 URI 转小写、去除末尾 /。

完整参数定义
{
  "name": "uri_match_type",
  "in": "query",
  "required": false,
  "description": "URI 匹配方式:`exact` 精确匹配(默认);`prefix` 以前缀匹配并将 URI 转小写、去除末尾 `/`。",
  "schema": {
    "type": "string",
    "enum": [
      "exact",
      "prefix"
    ],
    "default": "exact"
  }
}
statusquerystring可选

三位 HTTP 状态码精确筛选。

完整参数定义
{
  "name": "status",
  "in": "query",
  "required": false,
  "description": "三位 HTTP 状态码精确筛选。",
  "schema": {
    "type": "string",
    "pattern": "^\\d{3}$",
    "example": "200"
  }
}
node_idquerystring可选

节点 ID(日志字段 nid),必须为数字。

完整参数定义
{
  "name": "node_id",
  "in": "query",
  "required": false,
  "description": "节点 ID(日志字段 nid),必须为数字。",
  "schema": {
    "type": "string",
    "example": "1001"
  }
}
cache_statusquerystring可选

缓存状态精确筛选。

完整参数定义
{
  "name": "cache_status",
  "in": "query",
  "required": false,
  "description": "缓存状态精确筛选。",
  "schema": {
    "type": "string",
    "enum": [
      "HIT",
      "MISS"
    ]
  }
}
methodquerystring可选

HTTP 方法精确筛选,仅允许 1 至 10 个英文字母。

完整参数定义
{
  "name": "method",
  "in": "query",
  "required": false,
  "description": "HTTP 方法精确筛选,仅允许 1 至 10 个英文字母。",
  "schema": {
    "type": "string",
    "example": "GET"
  }
}
tls_fpquerystring可选

JA4 TLS 指纹,必须为 36 个字母、数字或下划线。

完整参数定义
{
  "name": "tls_fp",
  "in": "query",
  "required": false,
  "description": "JA4 TLS 指纹,必须为 36 个字母、数字或下划线。",
  "schema": {
    "type": "string",
    "example": "t13d4907h2_0d8feac7bc37_7395dae3b2f3"
  }
}
countryquerystring可选

国家名称精确筛选。

完整参数定义
{
  "name": "country",
  "in": "query",
  "required": false,
  "description": "国家名称精确筛选。",
  "schema": {
    "type": "string"
  }
}
provincequerystring可选

省份名称精确筛选。

完整参数定义
{
  "name": "province",
  "in": "query",
  "required": false,
  "description": "省份名称精确筛选。",
  "schema": {
    "type": "string"
  }
}
cityquerystring可选

城市名称精确筛选。

完整参数定义
{
  "name": "city",
  "in": "query",
  "required": false,
  "description": "城市名称精确筛选。",
  "schema": {
    "type": "string"
  }
}
ispquerystring可选

运营商名称精确筛选。

完整参数定义
{
  "name": "isp",
  "in": "query",
  "required": false,
  "description": "运营商名称精确筛选。",
  "schema": {
    "type": "string"
  }
}
refererquerystring可选

Referer 精确筛选。

完整参数定义
{
  "name": "referer",
  "in": "query",
  "required": false,
  "description": "Referer 精确筛选。",
  "schema": {
    "type": "string"
  }
}
pagequeryinteger可选

页码,默认 1。服务端最多查询前 1000 条,超过范围时会调整页码。

完整参数定义
{
  "name": "page",
  "in": "query",
  "required": false,
  "description": "页码,默认 1。服务端最多查询前 1000 条,超过范围时会调整页码。",
  "schema": {
    "type": "integer",
    "minimum": 1,
    "default": 1
  }
}
limitqueryinteger可选

每页条数,默认 10;服务端会将超过 100 的值压缩为 100。

完整参数定义
{
  "name": "limit",
  "in": "query",
  "required": false,
  "description": "每页条数,默认 10;服务端会将超过 100 的值压缩为 100。",
  "schema": {
    "type": "integer",
    "minimum": 1,
    "maximum": 100,
    "default": 10
  }
}
get_countquerystring可选

任意非空值均启用仅计数模式;启用时不返回日志数组。

完整参数定义
{
  "name": "get_count",
  "in": "query",
  "required": false,
  "description": "任意非空值均启用仅计数模式;启用时不返回日志数组。",
  "schema": {
    "type": "string",
    "example": "1"
  }
}

响应

HTTP 200

成功、筛选参数错误和认证/网站归属错误均返回 HTTP 200。普通查询的总数由日志库返回,查询体设置 track_total_hits=1000。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

仅统计匹配数量时成功状态固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
datainteger必填

仅 get_count 非空时返回的匹配日志数量。

约束 / 默认值 / 示例
{
  "minimum": 0
}
oneOf · 2 · object
字段类型必填说明与约束
codeinteger必填

访问日志列表查询成功时固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
countinteger必填

当前筛选条件下日志库返回的匹配总数。

约束 / 默认值 / 示例
{
  "minimum": 0
}
dataarray <object>必填

当前页日志,按 time 倒序。

展开字段结构

当前页日志,按 time 倒序。

数组元素 · object
字段类型必填说明与约束
_idstring必填

日志文档 ID。

tls_fpstring必填

TLS 指纹,缺失时为空字符串。

host2string必填

附加 Host 字段,缺失时为空字符串。

countrystring必填

国家,缺失时为空字符串。

provincestring必填

省份,缺失时为空字符串。

citystring必填

城市,缺失时为空字符串。

nidstring必填

节点 ID。

statusstring必填

HTTP 状态码。

protocolstring必填

请求协议。

addrstring必填

客户端 IP。

bytes_sentinteger必填

响应发送字节数。

cache_statusstring必填

缓存状态。

up_resp_timeany必填

上游响应耗时,保持日志库原始类型。

hoststring必填

请求 Host。

server_portany必填

源站端口;日志缺失时为空字符串。

refererstring必填

Referer。

user_agentstring必填

User-Agent。

content_typestring必填

响应 Content-Type。

timestring必填

日志时间字段。

req_uristring必填

请求 URI。

up_recvany必填

上游接收字节数,保持日志库原始类型。

methodstring必填

HTTP 方法。

timestampany必填

Elasticsearch sort 时间戳,保持原始类型。

sipstring必填

源站 IP,缺失时为空字符串。

l1_cache_statusstring必填

一级缓存状态,缺失时为空字符串。

l2_cache_statusstring必填

二级缓存状态,缺失时为空字符串。

l2_ipstring必填

二级节点 IP,缺失时为空字符串。

latany必填

纬度,缺失时为空字符串。

lngany必填

经度,缺失时为空字符串。

ispstring必填

运营商,缺失时为空字符串。

oneOf · 3 · object
字段类型必填说明与约束
codestring必填

时间、域名归属、IP、状态码、缓存状态、URI、端口、节点、方法、URI 匹配方式、TLS 指纹或认证失败的业务错误码。

约束 / 默认值 / 示例
{
  "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"
  ]
}
msgstring必填

访问日志查询参数校验或认证失败的具体原因。

datastring必填

发生业务错误时固定返回空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 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"

查看完整接口 JSON