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
Authorization information
Request syntax
GET /logstores/{logstore}/shards/{shard} HTTP/1.1
Request parameters
Parameter | Type | Required | Description | Example |
---|
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
query | string | No | 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
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
JSON
format
{
"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 time | Summary of changes | Operation |
---|
Change time | Summary of changes | Operation |
---|---|---|
2024-09-06 | Add Operation | View Change Details |