跳转至

查询日志(新)

1. 接口描述

接口请求路径:POST /prod-api/waf/wafv3/log/V2/describeLogV2

describeLogV2 用于分页查询 WAF 访问/防护日志。同一接口通过 action[].metricName 区分能力:logs 返回分页明细,logTread 返回日志量时间趋势。可分两次请求,也可写在同一 action 数组中一次返回。

Token 获取方式见 密钥鉴权

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
action Array 查询项列表;至少一项
action.metricName String 统计指标,支持以下值:
logs:分页日志列表
logTread:日志量时间序列(拼写固定为 logTread
示例值:logs
action.pageNo Integer 页码,从 1 开始。logs 必填;logTread 不传
示例值:1
action.pageSize Integer 每页条数。logs 必填;logTread 不传
示例值:15
domains Array of String 域名过滤
示例值:[]
otherFilter Array 附属筛选条件;无筛选时传 []
otherFilter.oneVal String 筛选字段,支持以下值:
client_ip:客户端 IP
http_user_agent:User-Agent
domain:域名
url:请求 URI
status:HTTP 状态码
request_method:请求方法
server_port:端口
ua_os_name:操作系统
ua_name:浏览器
client_country_name:国家/地区
client_city_name:城市
rule_id:规则 ID
rule_tags:规则标签
waf_acl_id:策略组 ID
request_id:请求 ID
oid:套餐号
示例值:oid
otherFilter.twoVal String 比较方式,支持以下值:
eq:等于
ne:不等于
contain:包含(通配)
示例值:eq
otherFilter.threeVal Array of String 比较值列表。contain 取首个值
示例值:["203.0.113.10"]
searchHeader Object 额外筛选头
searchHeader.severityLevel String 风险等级,支持以下值:
高风险
中风险
低风险
示例值:高风险
searchHeader.action String 处置动作,支持以下值:
deny:拦截
pass:放行
示例值:deny
params.beginTime String 开始时间,格式 yyyy-MM-dd HH:mm:ss
示例值:2026-05-21 00:00:00
params.endTime String 结束时间,格式 yyyy-MM-dd HH:mm:ss
示例值:2026-05-21 23:59:59

3. 示例

示例1 分页查询日志列表

输入示例

{
  "action": [
    { "metricName": "logs", "pageNo": 1, "pageSize": 15 }
  ],
  "otherFilter": [],
  "params": {
    "beginTime": "2026-05-21 00:00:00",
    "endTime": "2026-05-21 23:59:59"
  }
}

代码调用

请将 {登录域名}token 替换为实际值。

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class DescribeLogV2Test {

    public static void main(String[] args) throws Exception {
        String url = "https://{登录域名}/prod-api/waf/wafv3/log/V2/describeLogV2";
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        String requestBody = "{"
                + "\"action\":[{\"metricName\":\"logs\",\"pageNo\":1,\"pageSize\":15}],"
                + "\"otherFilter\":[],"
                + "\"params\":{"
                + "\"beginTime\":\"2026-05-21 00:00:00\","
                + "\"endTime\":\"2026-05-21 23:59:59\""
                + "}"
                + "}";

        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpPost httpPost = new HttpPost(url);
            httpPost.setHeader("Authorization", "Bearer " + token);
            httpPost.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));

            try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
                int statusCode = response.getStatusLine().getStatusCode();
                String body = EntityUtils.toString(response.getEntity(), "UTF-8");
                System.out.println("Status Code: " + statusCode);
                System.out.println("Body: " + body);
            }
        }
    }
}
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://{登录域名}/prod-api/waf/wafv3/log/V2/describeLogV2"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "action": [
    {"metricName": "logs", "pageNo": 1, "pageSize": 15}
  ],
  "otherFilter": [],
  "params": {
    "beginTime": "2026-05-21 00:00:00",
    "endTime": "2026-05-21 23:59:59"
  }
}`)

    req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBody))
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer "+token)
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println("Status Code:", resp.StatusCode)
    fmt.Println("Body:", string(body))
}

输出示例

{
  "msg": "成功",
  "code": 200,
  "data": [
    {
      "metricName": "logs",
      "list": [
        {
          "oid": "202501032327876983",
          "requestId": "e8e2ebbcbc31f910d2fb08b71474fd24",
          "wafId": "148",
          "clientIp": "5.175.189.32",
          "hostPort": 443,
          "timeStamp": "2026-05-21T01:18:25.000Z",
          "severityLevel": "高风险",
          "response": { "httpCode": 417 },
          "request": {
            "method": "GET",
            "uri": "/wp-config.php.bak",
            "headers": { "Host": "wap.example.com" }
          },
          "rules": [
            {
              "ruleId": "920440",
              "ruleMessage": "URL文件扩展名受策略限制",
              "group": "基础防护规则",
              "severityLevel": "高风险"
            }
          ]
        }
      ]
    }
  ]
}

logTread 返回示例:

{
  "msg": "成功",
  "code": 200,
  "data": [
    {
      "metricName": "logTread",
      "objectArrayList": [
        [1747785600000, 120],
        [1747785900000, 85]
      ],
      "count": 205
    }
  ]
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
data Array 与请求 action 顺序对应;无数据时可能为 null
data[].metricName String logslogTread
data[].list Array logs 时为日志明细列表,结构同 查询请求日志明细data
data[].objectArrayList Array logTread 时为时序点,每项为 [毫秒时间戳, 计数]
data[].count Integer logTread 时的合计条数

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
附属查询条件的条件类型有误 otherFilter.twoVal 不是支持的比较方式
查询日志失败 查询执行失败或参数非法