Call the PullLogs operation to retrieve log data from a specified cursor position. This operation retrieves raw logs. To query or analyze logs, call the GetLogsV2 operation.
Operation description
Specify a shard to retrieve logs.
This operation supports reading data in only the Protocol Buffer format.
The Host in the request syntax consists of the project name and the Simple Log Service endpoint. Specify the project in the Host.
Try it now
Test
RAM authorization
Request syntax
GET /logstores/{logStore}/shards/{shardId}?type=log HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| project |
string |
Yes |
The name of the project. |
ali-test-project |
| logStore |
string |
Yes |
The name of the Logstore. |
ali-test-logstore |
| shardId |
integer |
Yes |
The ID of the shard in the Logstore. |
1 |
| cursor |
string |
Yes |
The cursor that specifies the start position from which to read data. |
MTQ0NzMyOTQwMTEwMjEzMDkwNA |
| count |
integer |
Yes |
The number of LogGroups to return. The value must be an integer from 1 to 1000. |
1000 |
| end_cursor |
string |
No |
The cursor that specifies the end position at which to stop reading data. |
MTU1NzA1NzQwMTEwMjEzMDkwCg |
| query |
string |
No |
The filter statement in the Structured Process Language (SPL) syntax. For more information, see SPL instructions. |
* | where userId='123' |
| Accept-Encoding |
string |
No |
The compression format of the data that the server returns. Only the lz4 format is supported. |
lz4 |
The following request headers are specific to the PullLogs operation:
Accept: application/x-protobuf
Accept-Encoding: lz4
The value of Accept-Encoding can be lz4, deflate, or double quotation marks ("").
Request example:
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 elements
|
Element |
Type |
Description |
Example |
| headers |
object |
||
| Content-Length |
string |
0 |
|
| Date |
string |
Sun, 27 May 2018 08:25:04 GMT |
|
| x-log-requestid |
string |
5B0A6B60BB6EE39764D458B5 |
|
| x-log-count |
string |
||
| x-log-cursor |
string |
||
| x-log-cursor-time |
string |
||
| x-log-end-of-cursor |
string |
||
| Content-Type |
string |
application/json |
|
| x-log-compresstype |
string |
||
| x-log-bodyrawsize |
string |
||
|
LogGroupList |
The compressed data in protobuf format. |
The following response headers are specific to the PullLogs operation:
x-log-cursor: The cursor for the next log to be read.
x-log-end-of-cursor: The cursor of the last log that is read in the current request.
x-log-count: The number of logs returned.
For information about the common response headers of Simple Log Service API operations, see Common response headers.
The response body contains data that is serialized in the protobuf format. The data may be compressed.
Examples
Success response
JSON format
{
"logGroupList": [
{
"Topic": "topic-test",
"Source": "192.1.1.1",
"LogTags": [
{
"Key": "key-test",
"Value": "value-test"
}
],
"LogItems": [
{
"Time": 1690254376,
"Contents": [
{
"Key": "key-test",
"Value": "value-test"
}
]
}
]
}
]
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.