Updated on 2023-06-13 GMT+08:00

Querying Consumption of Each Domain Name

You can query data within the past 90 days.

The time span ranges from 1 hour to 31 days.

You can specify up to 100 domain names at a query.

The start time and end time must be specified at the same time. Their values must be precise down to the millisecond, but exact, one hour or one day (00:00:00) intervals are allowed. If the time span is less than 7 days, the time granularity must be one hour, for example, 2020-07-01 08:00:00 and 2020-07-01 09:00:00. If the time span is longer than 7 days but shorter than 31 days, the time granularity must be a whole day, for example, 2020-07-01 00:00:00 and 2020-07-02 00:00:00.

If the start time and end time do not meet the requirements, the returned data may be different from what was expected.

Function

This API is used to query summary information about each domain name within a time range.

URI

GET /v1.0/cdn/statistics/domain

Request

Request parameters

Table 1 describes the request parameters.

Table 1 Request parameters

Parameter

Mandatory

Type

Description

start_time

No

Long

Specifies the start time of a query (timestamp, in milliseconds).

end_time

No

Long

Specifies the end time of a query (timestamp, in milliseconds).

domain_name

Yes

String

Specifies a domain name list. Use commas (,) to separate domain names. For example, www.test1.com,www.test2.com. The maximum number of domain names is 20.

stat_type

Yes

String

Specifies the types of statistics: bw (bandwidth), flux (traffic), bs_bw (retrieval bandwidth), bs_flux (retrieval traffic), bs_num (total number of retrieval requests), bs_fail_num (total number of failed retrievals), req_num (total number of requests), req_hit_rate (cache hit ratio), flux_hit_rate (traffic hit ratio), bs_fail_rate (retrieval failure rate), qps (requests per second), http_code_2xx (status code 2xx), http_code_3xx (status code 3xx), http_code_4xx (status code 4xx), and http_code_5xx (status code 5xx).

service_area

No

String

Valid values are mainland_china and outside_mainland_china. The default value is mainland_china. You cannot query retrieval metrics including bs_flux, bs_bw, and bs_fail_rate by service area.

enterprise_project_id

No

String

Enterprise project that the resource belongs to. This parameter is valid only when the enterprise project function is enabled. The value all indicates all projects. This parameter is mandatory when you use an IAM user to call this API.

Example request

Requested path

GET https://cdn.myhuaweicloud.com/v1.0/cdn/statistics/domain?start_time=1513094400000&end_time=1513180799346&domain_name=example1.example2.com,example3.example4.com&interval=300&stat_type=flux&enterprise_project_id=0

Response

Response parameters

Table 2 describes the response parameter.

Table 2 Response parameter

Parameter

Type

Description

domain

Object

Specifies the domain name statistics. For details, see Table 3.

domain parameter description

Table 3 describes the parameters.

Table 3 domain parameter description

Parameter

Type

Description

start_time

Integer

Specifies the start time of a query (timestamp, in milliseconds).

end_time

Integer

Specifies the end time of a query (timestamp, in milliseconds).

value

Integer

Specifies the queried total traffic. The traffic unit is byte. The bandwidth unit is bit/s.

stat_type

String

Specifies the statistics type.

domain_name

String

Specifies the domain name.

service_area

String

Valid values are mainland_china (Chinese mainland) and outside_mainland_china (outside the Chinese mainland). You cannot query retrieval metrics by service area.

Example response
{
    "domain": 
     [
        {
            "value": 197400,
            "start_time": 1513094400000,
            "end_time": 1513180799346,
            "stat_type": "flux",
            "domain_name": "example1.example2.com",
            "service_area": "mainland_china"
        },
        {
            "value": 42825,
            "start_time": 1513094400000,
            "end_time": 1513180799346,
            "stat_type": "flux",
            "domain_name": "example3.example4.com",
            "service_area": "mainland_china"
        }
    ]
}

Status Code

See Status Codes.

Error Code

See Error Codes.