Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com> Co-authored-by: liusiying01 <liusiying@huawei.com> Co-committed-by: liusiying01 <liusiying@huawei.com>
5.1 KiB
Collecting Logs Using APIs
You can report logs to LTS with REST APIs. LTS supports APIs for reporting logs and high-precision logs.
API |
Log Time |
Example |
Scenario |
|---|---|---|---|
When invoking the API to upload a batch of logs, you can specify an initial time with log_time_ns field. The time of each log increases in ascending order based on the value of log_time_ns. |
{
"log_time_ns": "1586850540000000000",
"contents": [
"log1",
"log2"
"log3"
],
"labels": {
"user_tag": "string"
}
}
When reported to LTS: The time of log1 is 1586850540000000000. The time of log2 is 1586850540000000001. The time of log3 is 1586850540000000002. |
The logs are generated in sequence at similar time. |
|
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":"log4"
},
{
"log_time_ns":"1586850540000000008",
"log":"log5"
}
],
"labels":{
"user_tag":"string"
}
}
When reported to LTS: The time of log4 is 1586850540000000000. The time of log5 is 1586850540000000008. |
The uploaded logs are generated out of order at different times. Each log needs to have its own timestamp. |