查询规则触发占比¶
1. 接口描述¶
接口请求路径:POST /prod-api/waf/wafv3/statistic/describeRulesProportion
describeRulesProportion 用于统计指定时间范围内按规则类型划分的触发次数,返回自定义规则、限速规则、托管规则三类占比,常用于饼图/柱状图。服务端根据日志字段 transaction.messages.details.tags 分类聚合;无需在 action 中传指标名。
仅支持查询最近 180 天内的数据;单次最多查询 30 个域名。Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| action | 是 | Array | 固定传 [],本接口不使用该字段 |
| domains | 否 | Array of String | 域名过滤;单次最多 30 个 示例值: [] |
| otherFilter | 否 | Array | 附属筛选条件;无筛选时传 [] |
| otherFilter.oneVal | 否 | String | 筛选字段,支持以下值:client_ip:客户端 IPdomain:域名status:HTTP 状态码oid:套餐号rule_id:规则 IDwaf_acl_id:策略组 ID示例值: oid |
| otherFilter.twoVal | 否 | String | 比较方式,支持以下值:eq:等于ne:不等于示例值: eq |
| otherFilter.threeVal | 否 | Array of String | 比较值列表 示例值: ["20240412279097884616"] |
| params.beginTime | 是 | String | 开始时间,格式 yyyy-MM-dd HH:mm:ss示例值: 2026-05-20 16:49:02 |
| params.endTime | 是 | String | 结束时间,格式 yyyy-MM-dd HH:mm:ss示例值: 2026-05-20 17:49:02 |
3. 示例¶
示例1 查询三类规则触发占比¶
输入示例¶
{
"action": [],
"otherFilter": [],
"params": {
"beginTime": "2026-05-20 16:49:02",
"endTime": "2026-05-20 17:49:02"
}
}
代码调用¶
请将 {登录域名}、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 DescribeRulesProportionTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/waf/wafv3/statistic/describeRulesProportion";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"action\":[],"
+ "\"otherFilter\":[],"
+ "\"params\":{"
+ "\"beginTime\":\"2026-05-20 16:49:02\","
+ "\"endTime\":\"2026-05-20 17:49:02\""
+ "}"
+ "}";
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/statistic/describeRulesProportion"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"action": [],
"otherFilter": [],
"params": {
"beginTime": "2026-05-20 16:49:02",
"endTime": "2026-05-20 17:49:02"
}
}`)
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": {
"customRule": 1280,
"customLimitRule": 320,
"custodyRule": 5600
}
}
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:成功 |
| data | Object | 三类规则触发次数(非数组) |
| data.customRule | Integer | 自定义规则触发次数。示例值:1280 |
| data.customLimitRule | Integer | 自定义限速规则触发次数。示例值:320 |
| data.custodyRule | Integer | 托管规则(含 OWASP CRS 等)触发次数。示例值:5600 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| 请选择时间范围 | 未传 params 或缺少 beginTime / endTime |
| 只能查询最近180天的数据 | 开始时间超出限制,或时间跨度超过 180 天 |
| 一次性最多查询30个域名 | domains 超过 30 个 |
| 附属查询条件的条件类型有误 | otherFilter.twoVal 不是支持的比较方式 |
| 查询失败,请确认查询参数是否合法 | 查询执行失败或参数非法 |