Sends multiple logs to Log Service in one request.
Usage notes
-
An AccessKey pair is created and obtained. For more information, see AccessKey pair.
The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in Log Service is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. Make sure that the RAM user has the management permissions on Log Service resources. For more information, see Create a RAM user and authorize the RAM user to access Log Service.
- The information that is required to query logs is obtained. The information includes the name of the project to which the logs belong, the region of the project, and the name of the Logstore to which the logs belong. For more information, see Manage a project and Manage a Logstore.
- You can call this operation to collect logs from web pages or clients.
- If you use web tracking to collect logs and you do not call this operation, you can send only one log to Log Service in a request. For more information, see Use web tracking to collect logs.
- If you want to collect a large amount of log data, you can call this operation to send multiple logs to Log Service in one request.
- Before you can call this operation to send logs to a Logstore, you must enable web tracking for the Logstore. For more information, see Use web tracking to collect logs.
- You cannot call this operation to send the logs of multiple topics to Log Service at a time.
- If you call this operation, anonymous users from the Internet are granted the write permissions on the Logstore. This may generate dirty data because AccessKey pair-based authentication is not performed.
Debugging
Request headers
This operation uses only common request headers. For more information, see Common request headers.
Request syntax
POST /logstores/{logstoreName}/track HTTP/1.1
Request parameters
Parameter | Type | Position | Required | Example | Description |
---|---|---|---|---|---|
project | String | Host | Yes | ali-test-project | The name of the project. |
logstoreName | String | Path | Yes | ali-test-logstore | The name of the Logstore. |
Object | Body | Yes | The body of the request. |
||
__topic__ | String | Body | No | topic | The topic of the logs. |
__source__ | String | Body | Yes | source | The source of the logs. |
__logs__ | Array of Object | Body | Yes | The logs. |
|
__tags__ | Map | Body | No | { "tag1": "value1", "tag2": "value2" } | The tags of the logs. |
String | Body | No | { "tag1": "value1", "tag2": "value2" } | The tag of the log. |
Only the following request headers are supported. The first two request headers are required when you call the PutWebTracking operation. For more information about the formats and descriptions of the request headers, see Common request headers.
- x-log-apiversion: 0.6.0
- x-log-bodyrawsize: 1234
- x-log-compresstype: lz4
The x-log-compresstype header is required only when you need to send compressed data. To send compressed data, you must use the LZ4 or DEFLATE algorithm. You can specify x-log-compresstype: lz4
or x-log-compresstype: deflate
. For more information about how to compress data, see Data compression.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Server | String | nginx | The name of the server. |
Content-Type | String | application/json | The type of the response body. |
Content-Length | String | 0 | The length of the response body. |
Connection | String | close | Indicates whether the connection is persistent. Valid values:
|
Date | String | Sun, 27 May 2018 08:25:04 GMT | The time when the response was returned. |
x-log-requestid | String | 5B0A6B60BB6EE39764D458B5 | The request ID. |
Examples
Sample requests
POST /logstores/ali-test-logstore/track HTTP/1.1
Host:ali-test-project.cn-hangzhou.log.aliyuncs.com
Content-Type:application/json
{
"__topic__" : "topic",
"__source__" : "source",
"__logs__" : [
{
"key1": "value1",
"key2": "value2"
},
{
"key1": "value1",
"key2": "value2"
}
],
"__tags__" : {
"tag1": "value1",
"tag2": "value2"
}
}
Sample success responses
JSON
format
HTTP/1.1 200 OK
Error codes
For a list of error codes, see Service error codes.
HTTP status code |
Error code |
Error message |
Description |
---|---|---|---|
404 |
ProjectNotExist |
Project does not exist. |
The specified project does not exist. |
404 |
LogStoreNotExist |
Logstore does not exist. |
The specified Logstore does not exist. |
400 |
PostBodyInvalid |
Fail to parse protobuf. |
The logs in the Protobuf format are invalid and cannot be parsed. |
400 |
PostBodyInvalid |
Body invalid error message. |
The request body is invalid. |
400 |
PostBodyUncompressError |
Post body uncompressed fail. |
A log fails to be decompressed. |
400 |
PostBodyTooLarge |
Body size bodySize must little than 10485760. |
The request body before compression exceeds 10 MB in size. |
500 |
InternalServerError |
Specified Server Error Message. |
An internal server error has occurred. |
For more information, see Common error codes.