Combines multiple logs into one request.

If you want to collect logs by calling PutWebTracking, you must first enable Web Tracking for the destination Logstore where you want to store logs. This API action is suitable to the scenarios where larger numbers of logs needto be collected. For example, it would be suitable to call this API if you wanted to collect logs through a web page or a client.

You can also use the Web Tracking feature to collect logs. However, with Web Tracking, you can only write one log into a single request. For more information, see Web Tracking.

Request syntax

POST {project}.{endpoint}/logstores/{logstoreName}/track HTTP/1.1

x-log-apiversion: 0.6.0
x-log-bodyrawsize: 1234
x-log-compresstype: gzip

{
  "__topic__": "topic",
  "__source__": "source",
  "__logs__": [
    {
      "__time__": 1234567,
      "key1": "value1",
      "key2": "value2"
    },
    {
      "__time__": 1234567,
      "key1": "value1",
      "key2": "value2"
    }
  ],
  "__tags__": {
    "tag1": "value1",
    "tag2": "value2"
  }
}

Request parameters

Table 1. URL parameters
Parameter Type Required? Description
logstoreName String Yes The Logstore name.
endpoint String Yes The endpoint of Log Service. For more information, see Service endpoint.
project String Yes The Project name.
Table 2. Request body parameters
Parameter Type Required? Description
__topic__ String No The log topic.
__source__ String Yes The log source.
__logs__ List Yes The log list. Each element in the list is a JSON object, which represents a log. Each log must contain the time field. This field indicates the time the log is generated. The value of the time field is in the format of a UNIX timestamp. For example, 1558944742.
__tags__ Object No The log tage.

Request header

A request can contain the following three request headers:
  • x-log-apiversion: 0.6.0
  • x-log-bodyrawsize: 1234
  • x-log-compresstype: gzip
The first two request headers are required, and the third one is optional. For information about the format and description of the request headers, see Public request header.

Response header

The PutWebtracking interface does not have a special response header. For more information, see Public response header.

Response elements

No response element is returned when you call this action.

Examples

Request example
POST my-project.cn-hangzhou.log.aliyuncs.com/logstores/logstore-test/track HTTP/1.1

x-log-apiversion: 0.6.0
x-log-bodyrawsize: 1234
x-log-compresstype: gzip

{
  "__topic__": "topic",
  "__source__": "source",
  "__logs__": [
    {
      "__time__": 1558941776,
      "foo": "bar",
      "foo1": "bar1"
    },
    {
      "__time__": 1558941776,
      "bar": "foo",
      "bar1": "foo1"
    }
  ],
  "__tags__": {
    "tag1": "value1",
    "tag2": "value2"
  }
}
Response example
HTTP/1.1 200 OK
Header:
{
Date=Wed, 20 May 2019 07:35:00 GMT, 
Content-Length=0, 
x-log-requestid=5642EFA499248C827B012B39, 
Connection=close, 
Server=nginx/1.6.1
}