All Products
Search
Document Center

Web Application Firewall:DescribeSecurityEventTopNMetric

Last Updated:Jul 06, 2026

Queries the top N statistics of attack traffic, which is aggregated by a specified dimension, sorted, and returned.

Operation description

Attack traffic refers to requests that have rule hits and are identified as risky. The following three types of data are excluded:

  • Requests that hit whitelist rules.

  • Requests that hit bot rules but whose rule action is set to "back-to-origin marking".

  • Requests that hit rules with actions set to "dynamic token", "slider", "strict slider", or "JS authenticate", but the user passes the verification and the requests are allowed.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

yundun-waf:DescribeSecurityEventTopNMetric

get

*All Resource

*

  • acs:ResourceGroupId
None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the WAF instance.

Note

You can call DescribeInstance to query the ID of the current WAF instance.

waf_cdnsdf3****

Filter

object

Yes

The query filter conditions. Multiple filter conditions are evaluated using a logical AND.

DateRange

object

Yes

The query time range.

StartDate

integer

Yes

The query data range cannot exceed the past 30 days. The start time used for querying data, expressed as a UNIX timestamp. Unit: seconds.

Note

The start time must be later than the current time minus 30 days.

1713888000

EndDate

integer

Yes

The end time used for querying data, expressed as a UNIX timestamp. Unit: seconds.

1713888600

Conditions

array<object>

No

The list of filter conditions. Each node describes a filter condition.

object

No

The configuration of a single query condition. A query condition consists of a field name, an operator, and filter values. For the supported field names and operators in query conditions, see Supplementary description of request parameters.

Key

string

No

The field name on which the filter operation is performed. This operation supports all fields.

matched_host

OpValue

string

No

The operator.

eq

Values

any

No

The filter values.

test.waf-top

Limit

integer

Yes

The number of data entries to return after the statistics are sorted in descending order. Maximum value: 10.

10

Metric

string

Yes

Specifies the type of data to return. Different Metric values correspond to different data content. The following Metric values are supported by this API operation:

Note

The definition of "attack request" is described in the API operation description. The following descriptions reference this concept.

  • real_client_ip: performs aggregation and sorting of the source IP addresses of attack requests in descending order, and returns the top N entries.

  • http_user_agent: performs aggregation and sorting of the User-Agent values of attack requests in descending order, and returns the top N entries.

  • matched_host: performs aggregation and sorting of the protected objects hit by attack requests in descending order, and returns the top N entries.

  • remote_region_id: performs aggregation and sorting of the countries to which the source IP addresses of attack requests belong in descending order, and returns the top N entries.

  • request_path: performs aggregation and sorting of the URLs (excluding query strings) of attack requests in descending order, and returns the top N entries.

  • block_defense_scene: performs aggregation and sorting of the final action modules of blocked requests (whose action is not "monitor") in descending order, and returns the top N entries.

  • defense_scene: performs aggregation and sorting of all protection modules hit by attack requests in descending order, and returns the top N entries.

  • defense_scene_rule_id: queries the top rule IDs of hit non-monitor rules and the protection modules to which the rules belong. This query returns statistics only for non-monitor mode rules. The returned data format is as follows:
    { "Attribute": "waf_base", "Value": 140, "Name": "111034" }

  • defense_scene_with_rule_id: returns the top N rule IDs ranked by the number of hit requests and the protection modules to which the rules belong, connected by "-". This query does not distinguish between rule actions and includes both monitor rules and block rules. The returned format is as follows:
    { "Attribute": "", "Value": 1, "Name": "120075-waf_base" }

  • defense_scene_top_rule_id: queries the top rule hits of a specific protection module. Specify filter conditions in the Conditions field of Filter. For example, to query the top rule hits of the "custom ACL" module, set the Conditions field as follows:
    { "Key": "defense_scene_map", "OpValue": "contain", "Values": "custom_acl" }

  • defense_scene_rule_type: queries the top hit rule types of the web core protection module. Only the web core protection module supports this query because only web core protection has rule child classes. Specify filter conditions in the Conditions field of Filter. The format is as follows:
    { "Key": "defense_scene", "OpValue": "eq", "Values": "waf_base" }

real_client_ip

RegionId

string

No

The region where the WAF instance is deployed. Valid values:

  • cn-hangzhou: the Chinese mainland.

  • ap-southeast-1: outside the Chinese mainland.

cn-hangzhou

ResourceManagerResourceGroupId

string

No

The Alibaba Cloud resource group ID.

rg-acfm***q

Operator description

OperatorMeaningDescription
all-not-matchNot equal to any valueThe field value is not equal to any value in the data set. For example, to filter real_client_ip not equal to any value in the set:
{"Key":"real_client_ip","OpValue":"all-not-match","Values":["1.1.1.1","2.2.2.2","3.3.3.3"]}
containContainsThe field value contains a specific string. For example, to filter data where the URL contains "test":
{"Key":"request_path","OpValue":"contain","Values":"test"}
eqEqual toThe field value is equal to a specific string. For example, to filter data where the URL is "/testcase":
{"Key":"request_path","OpValue":"eq","Values":"/testcase"}
match-oneEqual to one of multiple valuesThe field value is equal to any value in the data set. For example, to filter real_client_ip equal to any value in the set:
{"Key":"real_client_ip","OpValue":"match-one","Values":["1.1.1.1","2.2.2.2","3.3.3.3"]}
neNot equal toThe field value is not equal to a specific string. For example, to filter statistics where the URL is not "/testcase":
{"Key":"request_path","OpValue":"ne","Values":"/testcase"}
not-containDoes not containThe field value does not contain a specific string. For example, to filter data where the URL does not contain "test":
{"Key":"request_path","OpValue":"not-contain","Values":"test"}
prefix-matchPrefix matchThe field value starts with a specific string. For example, to filter data where the URL starts with "/testcase":
{"Key":"request_path","OpValue":"prefix-match","Values":"/testcase"}
suffix-matchSuffix matchThe field value ends with a specific string. For example, to filter data where the URL ends with "/testcase":
{"Key":"request_path","OpValue":"suffix-match","Values":"/testcase"}

Supported keys for filter conditions

Field nameField descriptionSupported operators
actionThe protection action, which is the final action taken on the request.ne, eq
clusterThe protection cluster.ne, eq,
match-one,
all-not-match
defense_sceneThe protection module. A request may match multiple protection modules. Requests filtered by this field may also match other modules.ne, eq
hostThe host in the HTTP header.contain,
not-contain, ne, eq, match-one, all-not-match, prefix-match, suffix-match
http_cookieThe cookie in the HTTP header.contain,
not-contain, ne, eq, match-one,
all-not-match, prefix-match, suffix-match
http_user_agentThe User-Agent obtained from the HTTP header.contain,
not-contain, ne, eq, match-one,
all-not-match, prefix-match, suffix-match
matched_hostThe protected object.ne, eq,
match-one,
all-not-match
real_client_ipThe source IP address of the request. The parameter following the operator can only be an IP address string or a list of IP address strings. CIDR block queries are not supported.ne, eq,
match-one,
all-not-match
remote_country_idThe country to which the source IP address of the HTTP request belongs.ne, eq,
match-one,
all-not-match
remote_region_idThe province or city to which the source IP address of the HTTP request belongs.ne, eq,
match-one,
all-not-match
request_methodThe HTTP request method.ne, eq,
match-one,
all-not-match
request_pathThe HTTP request URL, excluding the query string.contain,
not-contain, ne, eq, match-one,
all-not-match, prefix-match, suffix-match
request_traceidThe unique ID that identifies the request.ne, eq,
match-one,
all-not-match
rule_idThe rule ID. A request may match multiple rules. Requests filtered by this field may also match other rules.ne, eq

Response elements

Element

Type

Description

Example

object

The returned data result. For format examples, see Examples.

RequestId

string

The request ID.

D827FCFE-90A7-4330-9326-*****B4C7726

SecurityEventTopNValues

array<object>

The array of top N statistics.

object

Each element corresponds to a top N statistics entry.

Name

string

The value of a specific field. The meaning varies depending on the queried Metric.

10000

Attribute

string

The additional information, such as the protection module to which a rule ID belongs.

waf_base

Value

integer

The statistical count used for top N sorting.

1111

TopNMetaData

object

The metadata of the returned data.

DateRange

object

The time range used for the query.

StartDate

integer

The start of the time range that was queried. The value is a UNIX timestamp. Unit: seconds. This value is the same as the `StartDate` request parameter.

1713888000

EndDate

integer

The end of the time range that was queried. The value is a UNIX timestamp. Unit: seconds. This value is the same as the `EndDate` request parameter.

1713888600

Units

string

The unit of the returned statistics.

requests

Examples

Success response

JSON format

{
  "RequestId": "D827FCFE-90A7-4330-9326-*****B4C7726\n",
  "SecurityEventTopNValues": [
    {
      "Name": "10000",
      "Attribute": "waf_base\n",
      "Value": 1111
    }
  ],
  "TopNMetaData": {
    "DateRange": {
      "StartDate": 1713888000,
      "EndDate": 1713888600
    },
    "Units": "requests\n"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 Waf.Report.%s Invalid parameter:%s. Invalid parameter:%s
400 Waf.Report.InternalError Server error occurred in report service. Report Service Internal Error

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.