Help Center/ Cloud Firewall/ API Reference/ API/ Log Analysis/ Querying Traffic Log Statistics
Updated on 2025-08-12 GMT+08:00

Querying Traffic Log Statistics

Function

This API is used to query traffic log statistics.

Calling Method

For details, see Calling APIs.

URI

GET /v1/{project_id}/cfw/logs/flow-statistic

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID, which is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

32-bit UUID.

Default Value

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

fw_instance_id

Yes

String

Definition

Firewall ID. It is a unique ID generated after a firewall instance is created. You can obtain the firewall ID by referring to Obtaining a Firewall ID.

Constraints

N/A

Range

32-bit UUID.

Default Value

N/A

range

No

Integer

Definition

Time range.

Constraints

N/A

Range

0 (last hour), 1 (last day), or 2 (last seven days)

Default Value

N/A

log_type

Yes

String

Definition

Log type.

Constraints

N/A

Range

internet (north-south logs), nat (NAT logs), vpc (east-west logs), or vgw (VGW logs)

Default Value

N/A

direction

No

String

Definition

Session direction.

Constraints

N/A

Range

in2out (outbound) or out2in (inbound)

Default Value

N/A

start_time

No

Long

Definition

Start time.

Constraints

N/A

Range

Milliseconds-level timestamp.

Default Value

N/A

end_time

No

Long

Definition

End time.

Constraints

N/A

Range

Milliseconds-level timestamp.

Default Value

N/A

vgw_id

No

Array of strings

Definition

VGW ID

Constraints

N/A

Range

32-bit UUID.

Default Value

N/A

asset_type

No

String

Definition

IP type.

Constraints

N/A

Range

public: EIP

private: private IP address

open_port

Default Value

N/A

item

Yes

String

Definition

Aggregation type.

Constraints

N/A

Range

src_ip: source IP address

dst_ip: destination IP address

dst_port: destination port

protocol: protocol

dst_host: destination domain name

app: application

dst_region_name: destination region

src_region_name: source region

risk_ip: unsafe IP address

risk_host: unsafe domain name

open_port: open port

Default Value

N/A

size

No

Integer

Definition

Number of aggregated records.

Constraints

N/A

Range

0 to 10

Default Value

5

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

data

data object

Definition

Traffic log statistics.

Range

N/A

Table 4 data

Parameter

Type

Description

records

Array of FlowDetailsVO objects

Definition

Statistics record.

Range

N/A

total

Long

Definition

Total number.

Range

N/A

Table 5 FlowDetailsVO

Parameter

Type

Description

apps

Array of ItemVO objects

Definition

Application statistics.

Range

N/A

associate_instance_type

String

Definition

Associated asset type.

Range

N/A

device_name

String

Definition

Associated asset name.

Range

N/A

item

String

Definition

Aggregation item.

Range

N/A

last_time

Long

Definition

Last access time.

Range

N/A

ports

Array of ItemVO objects

Definition

Port statistics.

Range

N/A

region

String

Definition

Region.

Range

N/A

request_byte

Double

Definition

Number of bytes in a request.

Range

N/A

response_byte

Double

Definition

Number of bytes in the response.

Range

N/A

sessions

Long

Definition

Number of sessions.

Range

N/A

tags

String

Definition

Tag.

Range

N/A

src_ip

Array of ItemVO objects

Definition

Source IP address.

Range

N/A

dst_ip

Array of ItemVO objects

Definition

Destination IP address.

Range

N/A

protocol

String

Definition

Protocol.

Range

N/A

Table 6 ItemVO

Parameter

Type

Description

key

String

Definition

Aggregation item.

Range

N/A

name

String

Definition

Aggregation item name.

Range

N/A

value

Long

Definition

Statistical value.

Range

N/A

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

Query the domain names accessing the external network. The project ID is a16df7cf1d094befa6bbc72cbf51e93a, the firewall ID is c598d612-8112-465c-bffd-863d4ce85a50, the time range is seven days, and the direction is outbound.

https://{Endpoint}/v1/a16df7cf1d094befa6bbc72cbf51e93a/cfw/logs/flow-statistic?fw_instance_id=c598d612-8112-465c-bffd-863d4ce85a50&log_type=internet&direction=in2out&item=dst_host&range=2&size=1000

Example Responses

Status code: 200

OK

{
  "data" : {
    "records" : [ {
      "apps" : [ {
        "key" : "HTTP",
        "value" : 11
      } ],
      "item" : "www.test.com",
      "last_time" : 1751355533000,
      "ports" : [ {
        "key" : "8080",
        "value" : 11
      } ],
      "request_byte" : 5357,
      "response_byte" : 4862,
      "sessions" : 11
    } ],
    "total" : 1
  }
}

Status code: 400

Bad Request

{
  "error_code" : "CFW.00200007",
  "error_msg" : "Incorrect time range."
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

Error Codes

See Error Codes.