Updated on 2025-03-28 GMT+08:00

Collecting Logs Using APIs

You can report logs to LTS with REST APIs. LTS supports APIs for reporting logs and high-precision logs.

The application scenarios and access domain names of the two APIs are as follows:

Table 1 Scenarios

API

Log Time

Example

Scenario

Reporting Logs

When invoking the API to upload a batch of logs, you can specify an initial time with log_time_ns field.

Time of each log can be calculated with log_time_ns+sequence count.

{
	"log_time_ns": "1586850540000000000",
	"contents": [
		"log1",
		"log2"
	],
	"labels": {
		"user_tag": "string"
	}
}

When reported to LTS:

The time of log1 is 1586850540000000000.

The time of log2 is 1586850540000000001.

The logs are generated in sequence at similar time.

Reporting High-Precision Logs

When you invoke the API to upload a batch of logs, the log_time_ns field must be used to specify the log time for each log.

{
    "contents":[
        {
            "log_time_ns":"1586850540000000000",
            "log":"log3"
        },
        {
            "log_time_ns":"1586850540000000008",
            "log":"log4"
        }
    ],
    "labels":{
        "user_tag":"string"
    }
}

When reported to LTS:

The time of log3 is 1586850540000000000.

The time of log4 is 1586850540000000008.

The uploaded logs are generated out of order at different times. Each log needs to have its own timestamp.

Table 2 Access domain names

Region Name

Region

Access Domain Name (Endpoint)

LA-Sao Paulo1

sa-brazil-1

lts-access.sa-brazil-1.myhuaweicloud.com

AP-Jakarta

ap-southeast-4

lts-access.ap-southeast-4.myhuaweicloud.com

LA-Santiago

la-south-2

lts-access.la-south-2.myhuaweicloud.com

ME-Riyadh

me-east-1

lts-access.me-east-1.myhuaweicloud.com

LA-Mexico City2

la-north-2

lts-access.la-north-2.myhuaweicloud.com

TR-Istanbul

tr-west-1

lts-access.tr-west-1.myhuaweicloud.com

LA-Mexico City1

na-mexico-1

lts-access.na-mexico-1.myhuaweicloud.com

AF-Cairo

af-north-1

lts-access.af-north-1.myhuaweicloud.com

AP-Manila

ap-southeast-5

lts-access.ap-southeast-5.myhuaweicloud.com

LA-Medellin-SENACESGE

la-south-205

lts-access.la-south-205.myhuaweicloud.com

LA-Queretaro-TotalCloud-KioQueretaro

la-north-203

lts-access.la-north-203.myhuaweicloud.com