Queries logs based on the specified cursors.

Description

  • You must specify the shard from which you want to query logs.
  • You can query only logs in the Protocol Buffers (protobuf) format. For more information, see Data encoding.
  • The value of the Host parameter consists of a project name and a Log Service endpoint. You must specify a project in the Host parameter when you call this API operation.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

The PullLogs operation does not have operation-specific request headers and uses only common request headers. For more information, see Common request headers.

Request syntax

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

Request parameters

ParameterTypePositionRequiredExampleDescription
projectStringHostYesali-test-project

The name of the project.

logstoreStringPathYessls-test-logstore

The name of the Logstore.

shardLongPathYes0

The ID of the shard.

typeStringQueryYeslogs

The type of the resource that you want to request. Set the value to logs.

cursorStringQueryYesMTQ0NzMyOTQwMTEwMjEzMDkwNA

The start cursor from which the system starts to read logs.

countLongQueryYes1000

The number of log groups to return. Valid values: 1 to 1000.

end_cursorStringQueryNoMTU1NzA1NzQwMTEwMjEzMDkwCg

The end cursor at which the system stops reading logs.

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

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

The valid values of the Accept-Encoding header are lz4, deflate, and a pair of double quotation marks ("").

Response parameters

ParameterTypeExampleDescription
ServerStringnginx

The name of the server.

Content-TypeStringapplication/json

The type of the content.

Content-LengthString0

The length of the content.

ConnectionStringclose

Indicates whether the connection is persistent. Valid values:

  • close: The connection is non-persistent. A new TCP connection is established for each HTTP request.
  • keep-alive: The connection is persistent. After a TCP connection is established, the connection remains open, and no more time or bandwidth is consumed to establish new connections.
x-log-compresstypeString*

The compression format.

DateStringSun, 27 May 2018 08:25:04 GMT

The time at which the response was returned.

x-log-requestidString5B0A6B60BB6EE39764D458B5

The unique ID of the request. The ID is generated by Log Service.

x-log-countString5

The total number of returned logs.

x-log-bodyrawsizeString0

The size of the compressed request body.

x-log-cursorStringMTQ0NzMyOTQwMTEwMjEzMDkwNA

The cursor of the next log.

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

  • x-log-cursor: the cursor of the log that follows the position at which the system stops reading logs.
  • x-log-end_cursor: The end cursor at which the system stops reading logs.
  • x-log-count: the number of returned logs.

For information about the common response headers that are supported by the Log Service API, see Common response headers.

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

Examples

Sample requests

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

Sample success responses

JSON format

HTTP/1.1 200 OK

Description of the sample response

To flip the page and obtain the next token without returning data, you can send an HTTP HEAD request. 

Error codes

For a list of error codes, visit the API Error Center.

HttpStatusCode

ErrorCode

ErrorMessage

Description

404

LogStoreNotExist

Logstore does not exist.

The error message returned because the specified Logstore does not exist.

400

ParameterInvalid

Invalid cursor.

The error message returned because the value of the cursor parameter is invalid.

400

ParameterInvalid

ParameterCount should be in [0-1000].

The error message returned because the value of the count parameter is invalid. The valid values of the count parameter are within the range of 0 to 1000.

400

ShardNotExist

Shard does not exist.

The error message returned because the specified shard does not exist.

400

InternalServerError

Specified Server Error Message.

The error message returned because an internal server error has occurred.

For more information, see Common error codes.