Retrieves log data at a specified cursor position by calling the PullLogs operation. This operation retrieves raw logs. To query or analyze logs, use the GetLogsV2 operation.
Operation description
You must specify a shard when retrieving logs.
Only data in Protocol Buffer format is supported.
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
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| logStore |
string |
Yes |
The name of the Logstore. |
ali-test-logstore |
| shardId |
integer |
Yes |
The ID of the shard in the Logstore. |
1 |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| project |
string |
Yes |
The name of the project. |
ali-test-project |
| cursor |
string |
Yes |
The cursor that indicates the start position from which to read data. |
MTQ0NzMyOTQwMTEwMjEzMDkwNA |
| count |
integer |
Yes |
The maximum number of log groups to return. Minimum value: 1. Maximum value: 1000. |
1000 |
| end_cursor |
string |
No |
The end cursor that indicates the position at which to stop reading data. The data at this position is not included. |
MTU1NzA1NzQwMTEwMjEzMDkwCg |
| query |
string |
No |
The filter statement in SPL syntax. For more information, see SPL instructions. |
* | where userId='123' |
| Accept-Encoding |
string |
No |
The expected compression format of the data returned by the server. The value lz4 is supported. |
lz4 |
The following request headers are specific to the PullLogs operation:
Accept: application/x-protobuf
Accept-Encoding: lz4
The Accept-Encoding value 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 |
| LogGroupList |
The compressed Protocol Buffer data. |
The following response elements are specific to the PullLogs operation:
x-log-cursor: The cursor for the next entry after the current data read.
x-log-end-of-cursor: The cursor for the last entry of the current data read.
x-log-count: The number of entries returned.
For information about common response headers of Simple Log Service API, see Common response headers.
The response elements are data serialized in Protocol Buffer format, which may be compressed.
Examples
Success response
JSON format
{
"logGroupList": [
{
"LogItems": [
{
"Contents": [
{
"Key": "key-test",
"Value": "value-test"
}
],
"Time": 1690254376,
"TimeNs": 123456789
}
],
"LogTags": [
{
"Key": "key-test",
"Value": "value-test"
}
],
"Source": "192.1.1.1",
"Topic": "topic-test"
}
]
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.