Pulls logs iteratively from a specified cursor position. Use this command to retrieve large volumes of log data.
Request syntax
aliyunlog log pull_logs --project_name=<value> --logstore_name=<value> --shard_id=<value> --cursor=<value> [--count=<value>] [--end_cursor=<value>] [--compress=<value>] [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>]
Request parameters
Command-specific parameters:
|
Parameter |
Type |
Required |
Example |
Description |
|
--project_name |
String |
Yes |
aliyun-test-project |
The project name. |
|
--logstore_name |
String |
Yes |
logstore-a |
The Logstore name. |
|
--shard_id |
Integer |
Yes |
0 |
The shard ID. |
|
--cursor |
String |
Yes |
MTYxNDc1MDAyNzM3MzIwNTcxNA== |
The cursor position to start reading logs from. |
|
--count |
Integer |
No |
2 |
The number of logs to read. |
|
--end_cursor |
String |
No |
MTYxNDc1MDAyNzM3MzIwNTcxNg== |
The cursor position to stop reading logs at. |
|
--compress |
Boolean |
No |
true |
Whether to compress returned logs. Valid values:
|
All SLS CLI commands also support Global parameters.
Examples
-
Request example
Query two logs from a specified cursor using the default account:
aliyunlog log pull_logs --project_name="aliyun-test-project" --logstore_name="logstroe-a" --shard_id=0 --cursor="MTYxNDc1MDAyNzM3MzIwNTcxNA==" --count="2" -
Response example
{ "count": 2, "logs": [ { "__source__": "203.0.113.10", "__tag__:__hostname__": "iZ3s******Z", "__tag__:__pack_id__": "81C4812927C6B529-15DA", "__tag__:__receive_time__": "1619597641", "__time__": 1619597638, "__topic__": "", "activity_id": "", "computer_name": "iZ3stckpfjj7wvZ", "event_id": "7036", "kernel_time": "0", "keywords": "[Classic]", "level": "Information", "log_name": "System", "message": "The Network Setup Service service entered the stopped state.", "message_error": "[]", "opcode": "", "process_id": "544", "processor_id": "0", "processor_time": "0", "provider_guid": "{555908d1-a6d7-4695-8e1e-26931d2012f4}", "record_number": "8623", "related_activity_id": "", "session_id": "0", "source_name": "Service Control Manager", "task": "", "thread_id": "3176", "type": "wineventlog", "user_data": "{\"xml_name\":\"\"}", "user_time": "0", "version": "0" }, { "__source__": "203.0.113.10", "__tag__:__hostname__": "iZ3******vZ", "__tag__:__pack_id__": "81C4812927C6B529-15DB", "__tag__:__receive_time__": "1619598347", "__time__": 1619598344, "__topic__": "", "activity_id": "", "computer_name": "iZ3stckpfjj7wvZ", "event_id": "7036", "kernel_time": "0", "keywords": "[Classic]", "level": "Information", "log_name": "System", "message": "The Windows Update service entered the running state.", "message_error": "[]", "opcode": "", "process_id": "544", "processor_id": "0", "processor_time": "0", "provider_guid": "{555908d1-a6d7-4695-8e1e-26931d2012f4}", "record_number": "8624", "related_activity_id": "", "session_id": "0", "source_name": "Service Control Manager", "task": "", "thread_id": "6868", "type": "wineventlog", "user_data": "{\"xml_name\":\"\"}", "user_time": "0", "version": "0" } ], "next_cursor": "MTYxNDc1MDAyNzM3MzIwNTcxNg==" }
Error codes
Resolve errors using the error codes below.
|
HttpStatusCode |
ErrorCode |
ErrorMessage |
Description |
|
404 |
LogStoreNotExist |
Logstore does not exist. |
The Logstore does not exist. |
|
400 |
ParameterInvalid |
Invalid cursor. |
The cursor is invalid. |
|
400 |
ParameterInvalid |
ParameterCount should be in [0-1000]. |
Invalid count value. Valid range: 0 to 1000. |
|
400 |
ShardNotExist |
Shard does not exist. |
The shard does not exist. |
|
400 |
InternalServerError |
Specified Server Error Message. |
Internal server error. |