查询 CC 攻击数据¶
1. 接口描述¶
接口请求路径:POST /prod-api/cdn/layer7/statistic/v2/describeL7CCAttack
describeL7CCAttack(V2)用于查询七层 CC 攻击相关的请求/拦截趋势。请求 action 中声明 accessTrend 后,返回会拆成 accessTrend_drop(拦截)与 accessTrend_access(放行)两条序列。
仅支持查询最近 360 天内的数据,单次查询时间跨度不超过 40 天;单次最多查询 30 个域名。Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| action | 是 | Array | 统计指标列表,不能为空 |
| action.metricName | 是 | String | 统计指标,支持以下值:accessTrend:请求数据趋势图(返回时拆为拦截/放行两条序列)示例值: accessTrend |
| action.pageNo | 否 | Integer | 页码,从 1 开始。当前指标无需分页 示例值: 1 |
| action.pageSize | 否 | Integer | 每页条数。当前指标无需分页 示例值: 10 |
| domains | 否 | Array of String | 域名过滤。空数组或不传表示当前账号全部域名;单次最多 30 个 示例值: [] |
| interval | 是 | String | 时间粒度,支持以下值:1m:1 分钟5m:5 分钟1h:1 小时1d:1 天示例值: 5m |
| otherFilter | 否 | Array | 附属筛选条件 |
| otherFilter.oneVal | 否 | String | 筛选字段标识 示例值: domain |
| otherFilter.twoVal | 否 | String | 比较方式,支持以下值:eq:等于ne:不等于示例值: eq |
| otherFilter.threeVal | 否 | Array of String | 比较值列表 示例值: ["example.com"] |
| params.beginTime | 是 | String | 开始时间,格式 yyyy-MM-dd HH:mm:ss,仅支持查询最近 360 天示例值: 2026-05-15 11:01:30 |
| params.endTime | 是 | String | 结束时间,格式 yyyy-MM-dd HH:mm:ss,单次跨度不超过 40 天示例值: 2026-05-18 11:01:30 |
3. 示例¶
示例1 查询请求/拦截趋势¶
输入示例¶
{
"action": [
{
"metricName": "accessTrend"
}
],
"interval": "5m",
"domains": [],
"params": {
"beginTime": "2026-05-15 11:01:30",
"endTime": "2026-05-18 11:01:30"
}
}
代码调用¶
请将 {登录域名}、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 DescribeL7CCAttackV2Test {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/cdn/layer7/statistic/v2/describeL7CCAttack";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"action\":[{\"metricName\":\"accessTrend\"}],"
+ "\"interval\":\"5m\","
+ "\"domains\":[],"
+ "\"params\":{"
+ "\"beginTime\":\"2026-05-15 11:01:30\","
+ "\"endTime\":\"2026-05-18 11:01:30\""
+ "}"
+ "}";
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/cdn/layer7/statistic/v2/describeL7CCAttack"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"action": [
{"metricName": "accessTrend"}
],
"interval": "5m",
"domains": [],
"params": {
"beginTime": "2026-05-15 11:01:30",
"endTime": "2026-05-18 11:01:30"
}
}`)
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": "accessTrend_drop",
"objectArrayList": [
[1778868900000, 0],
[1778869200000, 0],
[1778999700000, 1]
],
"total": 57
},
{
"metricName": "accessTrend_access",
"objectArrayList": [
[1778868900000, 12],
[1778869200000, 8],
[1778999700000, 3]
],
"total": 120
}
]
}
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:成功 |
| data | Array | 指标结果列表。请求 accessTrend 时固定返回两条:accessTrend_drop、accessTrend_access |
| data[].metricName | String | 指标名称,支持以下值:accessTrend_drop:拦截accessTrend_access:请求数(放行) |
| data[].objectArrayList | Array | 时间序列,每个点为 [毫秒时间戳, 数值] |
| data[].total | Integer | 该序列在查询区间内的合计值。示例值:57 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| 请选择时间范围 | 未传 params 或缺少 beginTime / endTime |
| 一次性最多查询30个域名 | domains 超过 30 个 |
| 只能查询最近360天的数据 | 开始时间超出限制 |
| 一次只能查询40天的数据 | 时间跨度超过 40 天 |
| 无效的interval | interval 不是 1m / 5m / 1h / 1d |
| 附属查询条件的条件类型有误 | otherFilter.twoVal 不是 eq / ne |
| 查询失败,请确认查询参数是否合法 | 查询执行失败或参数非法 |