Updated on 2024-04-12 GMT+08:00

Querying Resources by Time Segment

Function

Query resources by time segment.

URI

POST /v2/{project_id}/lts/timeline-traffic-statistics

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.

Default value: None.

Minimum length: 32 characters.

Maximum length: 32 characters.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

timezone

Yes

String

The time zone.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Default value: None.

Minimum length: 1000 characters.

Maximum length: 2000 characters.

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Default value: None.

Minimum length: 30 characters.

Maximum length: 30 characters.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

start_time

Yes

Long

Start timestamp of the query, in milliseconds. A maximum of 30 days are supported.

end_time

Yes

Long

End timestamp, in milliseconds.

period

Yes

String

Query interval, in hours. The value ranges from 1 to 24.

resource_type

Yes

String

Resource type: The value is log_group / log_stream / tenant.

search_type

No

String

The traffic type can be write, index, or storage.

resource_id

No

String

Resource ID. If the resource type is log_group, the value of resource_id is the log group ID. If the resource type is log_stream, the value of resource_id is the log stream ID.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

results

Array of Resulits objects

Response result.

Table 6 Resulits

Parameter

Type

Description

timestamp

Long

Timestamp, in milliseconds.

value

Double

Traffic, in bytes.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Error code. Minimum length: 8 characters. Maximum length: 36 characters.

errorMessage

String

Error description. Minimum length: 2 characters. Maximum length: 512 characters.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Error code. Minimum length: 8 characters. Maximum length: 36 characters.

errorMessage

String

Error description. Minimum length: 2 characters. Maximum length: 512 characters.

Example Requests

v2/2a473356cca5487f8373be891bffc1cf/lts/timeline-traffic-statistics

{
  "start_time" : 1668614400000,
  "end_time" : 1668787200000,
  "search_type" : "write",
  "period" : 1,
  "resource_type" : "tenant"
}

Example Responses

Status code: 200

Query succeeded.

{
  "results" : [ {
    "timestamp" : 1669046400000,
    "value" : 8.24859442E7
  }, {
    "timestamp" : 1669071600000,
    "value" : 0
  }, {
    "timestamp" : 1669161600000,
    "value" : 9.06895742E7
  }, {
    "timestamp" : 1669215600000,
    "value" : 8.81524816E7
  } ]
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "errorCode" : "LTS.0009",
  "errorMessage" : "resource_id must not be empty"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "errorCode" : "LTS.0203",
  "errorMessage" : "Internal Server Error"
}

Status Codes

Status Code

Description

200

Query succeeded.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.