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
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
Parameter | Type | Position | Required | Example | Description |
---|---|---|---|---|---|
project | String | Host | Yes | ali-test-project | The name of the project. |
logstore | String | Path | Yes | sls-test-logstore | The name of the Logstore. |
shard | Long | Path | Yes | 0 | The ID of the shard. |
type | String | Query | Yes | logs | The type of the resource that you want to request. Set the value to logs. |
cursor | String | Query | Yes | MTQ0NzMyOTQwMTEwMjEzMDkwNA | The start cursor from which the system starts to read logs. |
count | Long | Query | Yes | 1000 | The number of log groups to return. Valid values: 1 to 1000. |
end_cursor | String | Query | No | MTU1NzA1NzQwMTEwMjEzMDkwCg | 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
Parameter | Type | Example | Description |
---|---|---|---|
Server | String | nginx | The name of the server. |
Content-Type | String | application/json | The type of the content. |
Content-Length | String | 0 | The length of the content. |
Connection | String | close | Indicates whether the connection is persistent. Valid values:
|
x-log-compresstype | String | * | The compression format. |
Date | String | Sun, 27 May 2018 08:25:04 GMT | The time at which the response was returned. |
x-log-requestid | String | 5B0A6B60BB6EE39764D458B5 | The unique ID of the request. The ID is generated by Log Service. |
x-log-count | String | 5 | The total number of returned logs. |
x-log-bodyrawsize | String | 0 | The size of the compressed request body. |
x-log-cursor | String | MTQ0NzMyOTQwMTEwMjEzMDkwNA | 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.