跳转至

查询攻击数据

1. 接口描述

接口请求路径:POST /prod-api/waf/nlaV1/statistic/describeAttackData

describeAttackData 用于查询 HTTP DDoS(NLA)攻击/访问趋势时序数据。一次请求可在 action 中声明多个指标,返回的 dataaction 顺序一一对应;objectArrayList 中每个点为 [毫秒时间戳, 计数]

仅支持查询最近 180 天内的数据;单次最多查询 30 个域名。Token 获取方式见 密钥鉴权

2. 输入参数

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

参数名称 必选 类型 描述
action Array 统计指标列表,不能为空
action.metricName String 统计指标,支持以下值:
logTread:攻击/访问量时间序列(与控制台攻击趋势图对应)
block_thread:拦截趋势(自动追加状态码等于拦截态的筛选)
示例值:logTread
domains Array of String 域名过滤。空数组或不传表示当前账号全部域名;单次最多 30 个
示例值:[]
interval String 时间粒度,支持以下值:
1m:1 分钟
5m:5 分钟
1h:1 小时
1d:1 天
不传时按时间跨度自动选择
示例值:1m
otherFilter Array 附属筛选条件;无筛选时传 []
otherFilter.oneVal String 筛选字段,支持以下值:
oid:套餐
client_ip:来源 IP
domain:域名
url:URL
status:状态码
request_method:请求方法
server_port:端口
ua_os_name:操作系统
ua_name:浏览器
client_country_name:国家/地区
client_city_name:城市
acl_id:策略组
rule_Id:规则 ID
action:处置动作
bot_score:Bot 评分
request_id:请求 ID
hostname:主机名
timezone:时区
http_user_agent:User-Agent
示例值:oid
otherFilter.twoVal String 比较方式,支持以下值:
eq:等于
ne:不等于
gt:大于
lt:小于
gte:大于等于
lte:小于等于
示例值:eq
otherFilter.threeVal Array of String 比较值列表。范围比较(gt/lt/gte/lte)取首个值
示例值:["22"]
params.beginTime String 开始时间,格式 yyyy-MM-dd HH:mm:ss,仅支持查询最近 180 天
示例值:2026-05-12 16:49:56
params.endTime String 结束时间,格式 yyyy-MM-dd HH:mm:ss,单次跨度不超过 180 天
示例值:2026-05-15 16:49:56

3. 示例

示例1 查询攻击趋势

输入示例

{
  "action": [
    {
      "metricName": "logTread"
    }
  ],
  "otherFilter": [],
  "params": {
    "beginTime": "2026-05-12 16:49:56",
    "endTime": "2026-05-15 16:49:56"
  }
}

代码调用

请将 {登录域名}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 DescribeAttackDataTest {

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

        String requestBody = "{"
                + "\"action\":[{\"metricName\":\"logTread\"}],"
                + "\"otherFilter\":[],"
                + "\"params\":{"
                + "\"beginTime\":\"2026-05-12 16:49:56\","
                + "\"endTime\":\"2026-05-15 16:49:56\""
                + "}"
                + "}";

        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/nlaV1/statistic/describeAttackData"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "action": [
    {"metricName": "logTread"}
  ],
  "otherFilter": [],
  "params": {
    "beginTime": "2026-05-12 16:49:56",
    "endTime": "2026-05-15 16:49:56"
  }
}`)

    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": "logTread",
      "objectArrayList": [
        [1778686200000, 3],
        [1778686500000, 0]
      ],
      "total": 146
    }
  ]
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
data Array 指标结果列表,顺序与请求 action 一致
data[].metricName String 指标名称。示例值:logTread
data[].objectArrayList Array 时序点列表,每项为 [毫秒时间戳, 数值]
data[].total Integer 该指标合计请求数。示例值:146

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
请选择时间范围 未传 params 或缺少 beginTime / endTime
只能查询最近180天的数据 开始时间超出限制,或时间跨度超过 180 天
一次性最多查询30个域名 domains 超过 30 个
附属查询条件的条件类型有误 otherFilter.twoVal 不是支持的比较方式
分数查询条件不能为空 范围比较时 threeVal 为空
查询失败,请确认查询参数是否合法 查询执行失败或参数非法