All Products
Search
Document Center

Web Application Firewall:DescribeNetworkFlowTopNMetric

Last Updated:Sep 16, 2025

Queries the top N statistics for all traffic, including malicious and normal service requests. The results are aggregated by different dimensions and sorted in descending order.

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:DescribeNetworkFlowTopNMetric

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the WAF instance.

Note

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

waf_cdnsdf3****

Filter

object

Yes

The filter conditions for the query. Multiple filter conditions have a logical AND relationship.

DateRange

object

Yes

The time range to query.

StartDate

integer

Yes

The start of the time range to query. The range cannot exceed the last 30 days. Specify the time in the UNIX timestamp format. Unit: seconds.

Note

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

1713888000

EndDate

integer

Yes

The end of the time range to query. Specify the time in the UNIX timestamp format. Unit: seconds.

1713888600

Conditions

array

No

A list of filter conditions. Each node specifies a filter condition.

object

No

The configuration of a single filter condition. A filter condition consists of a field name, an operator, and a filter value. For more information about the supported field names and operators, see the Additional information about request parameters section.

Key

string

No

The field to filter. This parameter supports the following fields:

  • matched_host

  • cluster

matched_host

OpValue

string

No

The operator.

eq

Values

any

No

The filter value.

test.waf-top

Limit

integer

Yes

The number of entries to return. The data is sorted in descending order. The maximum value is 10.

10

Metric

string

Yes

The metric that you want to use to query data. Different metrics correspond to different data. This parameter supports the following metrics:

  • real_client_ip: Returns the top N source IP addresses of requests that are sent to WAF. The data is aggregated by source IP address and sorted in descending order.

  • http_user_agent: Returns the top N user agents of requests that are sent to WAF. The data is aggregated by user agent and sorted in descending order.

  • request_path: Returns the top N URLs that are requested. The data is aggregated by URL and sorted in descending order.

  • matched_host_by_total_requests: Returns the top N protected objects that receive the most requests and the number of requests that they receive.

  • matched_host_by_qps: Returns the top N protected objects that have the highest queries per second (QPS) and their QPS values.

  • matched_host_by_status: Returns the top N protected objects based on the WAF-returned HTTP status code. The data is aggregated by protected object and sorted in descending order. If you set Metric to this value, you must specify the status field in the Conditions parameter of Filter. The format to specify the status is as follows:
    {"Key":"status","OpValue":"eq","Values":"200"}



  • matched_host_by_upstream_status: Returns the top N protected objects based on the origin server-returned HTTP status code. The data is aggregated by protected object and sorted in descending order. If you set Metric to this value, you must specify the upstream_status field in the Conditions parameter of Filter. The format to specify the upstream status is as follows:
    {"Key":"upstream_status","OpValue":"eq","Values":"200"}



matched_host_by_upstream_status

RegionId

string

No

The region where the WAF instance resides. Valid values:

  • cn-hangzhou: the Chinese mainland.

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

cn-hangzhou

ResourceManagerResourceGroupId

string

No

The ID of the Alibaba Cloud resource group.

rg-acfm***q

Description of operators

OperatorMeaningDescription
all-not-matchDoes not equal any of the valuesThe field value is not equal to any value in the collection. For example, to filter real_client_ip addresses that are not equal to any value in a collection:
{"Key":"real_client_ip","OpValue":"all-not-match","Values":["1.XX.XX.1","2.XX.XX.2","3.XX.XX.3"]}



eqEqualsThe field value is equal to a string. For example, to filter statistics for which the URL is "/testcase":
{"Key":"request_path","OpValue":"eq","Values":"/testcase"}



match-oneEquals one of the valuesThe field value is equal to any value in the collection. For example, to filter real_client_ip addresses that are equal to any value in a collection:
{"Key":"real_client_ip","OpValue":"match-one","Values":["1.XX.XX.1","2.XX.XX.2","3.XX.XX.3"]}



neDoes not equalThe field value is not equal to a string. For example, to filter statistics for which the URL is not "/testcase":
{"Key":"request_path","OpValue":"ne","Values":"/testcase"}



Supported keys for filter conditions

Field nameField descriptionSupported operators
clusterThe protection cluster.ne, eq,
match-one,
all-not-match










matched_hostThe protected object.ne, eq,
match-one,
all-not-match










Response elements

Element

Type

Description

Example

object

The returned data. For more information about the format, see the Examples section.

RequestId

string

The request ID.

D827FCFE-90A7-4330-9326-******4C7726

NetworkFlowTopNValues

array<object>

An array of the top N statistics.

object

Each entry in the array represents a top N statistic.

Name

string

The value of a field. The meaning of this parameter varies based on the value of the Metric request parameter.

127.0.0.1

Attribute

string

Additional information. For example, this parameter can indicate the country or province to which an IP address belongs.

CN

Value

integer

The statistical count that is used for top N sorting.

1123

TopNMetaData

object

The metadata of the returned data.

DateRange

object

The time range that you specified for the query.

StartDate

integer

The start of the time range to query. This 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 to query. This 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 statistical data.

requests

Examples

Success response

JSON format

{
  "RequestId": "D827FCFE-90A7-4330-9326-******4C7726",
  "NetworkFlowTopNValues": [
    {
      "Name": "127.0.0.1",
      "Attribute": " CN",
      "Value": 1123
    }
  ],
  "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.