All Products
Search
Document Center

Simple Log Service:pull_log

Last Updated:Jun 02, 2026

Pulls log data from a specified shard within a given time range.

Request syntax

aliyunlog log pull_log --project_name=<value> --logstore_name=<value> --shard_id=<value> --from_time=<value> --to_time=<value> [--batch_size=<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

The following table describes the available parameters.

Parameter Name

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.

--from_time

String

Yes

2021-06-01 18:15:00+8:00

Start time. Use a UNIX timestamp or ”%Y-%m-%d %H:%M:%S<time_zone>” format. Example: ”2018-01-02 12:12:10+8:00”.

--to_time

String

Yes

2021-06-01 18:18:00+8:00

End time. Use a UNIX timestamp or ”%Y-%m-%d %H:%M:%S<time_zone>” format. Example: ”2018-01-02 12:12:10+8:00”.

--batch_size

String

No

1000

Number of logs per batch.

--compress

Boolean

No

true

Whether to compress returned log data.

  • true (default): Compress log data before returning.

  • false: Return log data uncompressed.

For shared CLI options, see Global parameters.

Examples

  • Request example

    Pull logs from a time range using the default account:

    aliyunlog log pull_log --project_name="ali-test-project" --logstore_name="nginx-moni" --shard_id=0 --from_time="2023-03-02 10:05:54" --to_time="2023-03-02 10:20:54" --format-output=json,no_escape
  • Response example

    {
      "count": 20,
      "logs": [
        {
          "__source__": "30.15.*.125",
          "__tag__:__client_ip__": "124.89.*.166",
          "__tag__:__receive_time__": "1719382997",
          "__time__": 1719382927,
          "__topic__": "",
          "request_method": "GET",
          "status": "200"
        },
        {
          "__source__": "30.15.*.125",
          "__tag__:__client_ip__": "124.89.*.166",
          "__tag__:__receive_time__": "1719382997",
          "__time__": 1719382927,
          "__topic__": "",
          "request_method": "POST",
          "status": "200"
        }
       ],
      "next_cursor": "MTcxOTIwOTUyMDQ5MjY3ODUxNw=="
    }
    {
      "count": 0,
      "logs": [],
      "next_cursor": "MTcxOTIwOTUyMDQ5MjY3ODUxNw=="
    }

For troubleshooting tips, see the CLI FAQ.