PullLogs

Updated at: 2025-03-28 03:27

Queries logs based on the specified cursors. You can call this operation to obtain raw logs. To query and analyze logs, you can call the GetLogsV2 operation.

Operation description

**

Warning You cannot call this operation in OpenAPI Explorer. You can use Simple Log Service SDK to call this operation. For more information, see SLS SDK Reference.

  • You must specify a shard when you query the logs.
  • You can query only logs in the Protocol Buffers (protobuf) format. For more information, see Data encoding.
  • Host consists of a project name and a Simple Log Service endpoint. You must specify a project in Host.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

GET /logstores/{logstore}/shards/{shard} HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
ParameterTypeRequiredDescriptionExample
querystringNo

The SPL statement that is used to filter data. For more information, see SPL instructions.

* | where userId='123'

The PullLogs operation has the following operation-specific request headers:

  • Accept: application/x-protobuf
  • Accept-Encoding: lz4

Valid values of Accept-Encoding: lz4, deflate, and "".

Sample request

GET /logstores/sls-test-logstore/shards/0?type=logs&cursor=MTQ0NzMyOTQwMTEwMjEzMDkwNA&count=1000 HTTP/1.1
Host:ali-test-project.cn-hangzhou.log.aliyuncs.com
Content-Type:application/json

Response parameters

ParameterTypeDescriptionExample
ParameterTypeDescriptionExample
headersobject
Content-Lengthstring
0
Datestring
Sun, 27 May 2018 08:25:04 GMT
x-log-requestidstring
5B0A6B60BB6EE39764D458B5
x-log-countstring
5
x-log-cursorstring
MTQ0NzMyOTQwMTEwMjEzMDkwNA
x-log-cursor-timestring
x-log-end-of-cursorstring
Content-Typestring
application/json
x-log-compresstypestring
*
x-log-bodyrawsizestring
0
LogGroupList

The PullLogs operation has the following operation-specific response elements:

  • x-log-cursor: the cursor of the next log.
  • x-log-end-of-cursor: the end cursor at which the system stops reading logs.
  • x-log-count: the number of returned logs.

For information about common response headers of Simple Log Service API operations, see Common response headers.

Serialized data in the protobuf format is returned. The data may be compressed.

Examples

Sample success responses

JSONformat

{
  "logGroupList": [
    {
      "Topic": "topic-test",
      "Source": "192.1.1.1",
      "LogTags": [
        {
          "Key": "key-test",
          "Value": "value-test"
        }
      ],
      "Logs": [
        {
          "Time": 1690254376,
          "Contents": [
            {
              "Key": "key-test",
              "Value": "value-test"
            }
          ]
        }
      ]
    }
  ]
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
Change timeSummary of changesOperation
2024-09-06Add OperationView Change Details
  • On this page (1)
  • Operation description
  • Debugging
  • Authorization information
  • Request syntax
  • Request parameters
  • Response parameters
  • Examples
  • Error codes
  • Change history
Feedback