Reporting Logs
Function
This API is used to report tenant logs from a HUAWEI CLOUD host to LTS. Currently, non-HUAWEI CLOUD hosts cannot report logs by APIs.
To obtain the access IP address, log in to the LTS console, choose Host Management in the navigation pane, and click Install ICAgent in the upper right corner. The access IP address is contained in the ICAgent installation command. The port number is 8102. You can check the Example Request to see how to add the access IP address and port number in a request.
URI
POST /v2/{project_id}/lts/groups/{log_group_id}/streams/{log_stream_id}/tenant/contents
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Identifies a project. For details about how to obtain the project ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID. No default value. Value length: 32 characters |
| log_group_id | Yes | String | Identifies a log group. For details about how to obtain the log group ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID. No default value. Value length: 36 characters |
| log_stream_id | Yes | String | Identifies a log stream. For details about how to obtain the log stream ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID. No default value. Value length: 36 characters The write rate should not be larger than 5 MB/s and up to 25,000 log events can be written per second for a single log stream. Otherwise, logs may be lost. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Indicates the user token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token. No default value. Minimum length: 1000 characters Maximum length: 2000 characters |
| Content-Type | Yes | String | Set this parameter to application/json;charset=utf8. No default value. Value length: 29 characters |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| log_time_ns | Yes | String | Indicates the log collection time (UTC time in nanoseconds). NOTE: The interval between the log collection time and current time must be less than the log retention duration. Otherwise, reported logs will be cleared. For example, if the log retention duration is seven days, the log collection time must be within the last seven days. |
| contents | Yes | Array of String | Indicates the log content. |
| labels | Yes | Map | Indicates custom labels. |
Response Parameters
When the status code is 200, the response parameters are as follows:
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Indicates the status code. Example value:
|
| errorMessage | String | Indicates the response description. Example value:
|
When the status code is 400, the response parameters are as follows:
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Indicates the error code. Example value:
|
| errorMessage | String | Indicates the error description. Example value:
|
When the status code is 401, the response parameters are as follows:
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Indicates the error code. Example value:
|
| errorMessage | String | Indicates the error description. Example value:
|
When the status code is 500, the response parameters are as follows:
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Indicates the error code. Example value:
|
| errorMessage | String | Indicates the error description. Example value:
|
When the status code is 503, the response parameter is as follows:
| Parameter | Type | Description |
|---|---|---|
| - | String | The requested service is unavailable. |
Example Request
POST https://{access_IP_address:8102}/v2/{project_id}/lts/groups/{log_group_id}/streams/{log_stream_id}/tenant/contents
{
"log_time_ns": "1586850540000000000",
"contents": [
"Fri Feb 1 07:48:04 UTC 2019 0\n",
"Sat Apri 18 16:04:04 UTC 2019"
],
"labels": {
"user_tag": "string"
}
} Example Response
Example response with status code 200:
Logs are reported.
{
"errorCode": "SVCSTG.ALS.200.200",
"errorMessage": "Report success.",
"result": null
} Example response with status code 401:
The authentication information is incorrect or invalid.
{
"errorCode" : "SVCSTG.ALS.403.105",
"errorMessage" : "Project id is invalid.",
"result": null
} Status Code
| Status Code | Description |
|---|---|
| 200 | The request has succeeded. |
| 400 | The request is invalid. Modify the request based on the description in error_msg before a retry. |
| 401 | The authentication information is incorrect or invalid. |
| 500 | An internal error occurred. |
| 503 | The requested service is unavailable. |
Error Codes
For details, see Error Code.
Last Article: Collecting Logs Using APIs
Next Article: Reporting High-Precision Logs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.