On this page

Show all

Collecting Logs Using APIs

Updated on 2025-02-12 GMT+08:00

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

The application scenarios and access IP addresses of the APIs are as follows:

Table 1 Scenarios

Name

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.

NOTE:

You can obtain the access IP address from the command displayed on the ICAgent installation page of the LTS console. For details, see Installing ICAgent (Intra-Region Hosts).

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback