Collecting Traffic Statistics on Top N Log Groups or Log Streams
Function
This API is used to collect traffic statistics on top n log groups or log streams.
URI
POST /v2/{project_id}/lts/topn-traffic-statistics
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
Request 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. Minimum: 1000 Maximum: 2000 |
| Content-Type | Yes | String | Set this parameter to application/json;charset=UTF-8. Minimum: 30 Maximum: 30 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| end_time | Yes | Long | End timestamp, in milliseconds. |
| start_time | Yes | Long | Start timestamp, in milliseconds. Data of the last 31 days can be queried. |
| is_desc | Yes | Boolean | Whether to sort data in descending order (true or false). |
| resource_type | Yes | String | Resource type. log_group: log group log_stream: log stream tenant: tenant |
| sort_by | Yes | String | Sorting. Data to be sorted must exist in search_list. index: index write: read and write storage: storage |
| topn | Yes | Integer | Number of data records to be queried. The value ranges from 1 to 100. |
| filter | Yes | Map<String,String> | Filter, which is in a map structure with keys as filtering attributes and values as attribute values. It does not support fuzzy match. The format for filter criteria is {"key": "xxxxxx"}, where key can be log_group_id or log_stream_id. |
| search_list | Yes | Array of strings | Query data type. Multiple string arrays can be used together. index: index write: read and write storage: storage |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| results | Array of ResultsTopnBody objects | Response result. |
| Parameter | Type | Description |
|---|---|---|
| index_traffic | Double | Index traffic, in bytes. This parameter is returned when the queried data type contains index. |
| storage | Double | Storage capacity, in bytes. This parameter is returned when the queried data type contains storage. |
| write_traffic | Double | Write traffic, in bytes. This parameter is returned when the queried data type contains write. |
| log_group_id | String | Log group ID. This parameter is returned when the resource type is log group. |
| log_group_name | String | Log group name. This parameter is returned when the resource type is log group. |
| log_stream_id | String | Log stream ID. This parameter is returned when the resource type is log stream. |
| log_stream_name | String | Log stream name. This parameter is returned when the resource type is log stream. |
| log_group_name_alias | String | When the resource type is set to log group, the log group alias is returned. By default, the log group alias is the same as the log group name. The alias is preferentially displayed. |
| log_stream_name_alias | String | When the resource type is set to log stream, the log stream alias is returned. By default, the log stream alias is the same as the log group name. The alias is preferentially displayed. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error message. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error message. |
Example Requests
Collecting Traffic Statistics on Top N Log Groups or Log Streams
POST /v2/2a473356cca5487f8373be891bffc1cf/lts/topn-traffic-statistics
{
"sort_by" : "storage",
"is_desc" : true,
"resource_type" : "log_stream",
"filter" : { },
"start_time" : 1668668183969,
"end_time" : 1669272983969,
"search_list" : [ "index", "write", "storage" ],
"topn" : 100
} Example Responses
Status code: 200
Query succeeded.
{
"results" : [ {
"index_traffic" : 517194820,
"is_agency_transfer" : false,
"log_stream_id" : "d2904b77-a5da-4fe2-96bf-89a44d92c33c",
"log_stream_name" : "lts-topic-3zvt",
"log_stream_name_alias" : "lts01",
"storage" : 21081842714,
"write_traffic" : 7.089894624E8
}, {
"index_traffic" : 330535554,
"is_agency_transfer" : false,
"log_stream_id" : "6844e13c-a69e-482e-b5fe-308d74adc722",
"log_stream_name" : "lts-topic-jifei",
"log_stream_name_alias" : "lts-topic-jifei",
"storage" : 529275068,
"write_traffic" : 6.60281602E7
} ]
} Status code: 400
BadRequest: Invalid request. Modify the request based on the description in errorMessage before a retry.
{
"errorCode" : "LTS.0208",
"errorMessage" : "The log stream does not existed"
} 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 | BadRequest: Invalid request. Modify the request based on the description in errorMessage before a retry. |
| 500 | The server has received the request but encountered an internal error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot