Queries the log data that is generated within a specified time range. This command iteratively obtains log data and returns the output. This command is suitable for scenarios in which you want to query a large amount of log data.

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 required and specific parameters of the pull_log command.
Parameter Type Required Example Description
--project_name String Yes aliyun-test-project The name of the project.
--logstore_name String Yes logstore-a The name of the Logstore.
--shard_id Integer Yes 0 The ID of the shard.
--from_time String Yes 2021-06-01 18:15:00+8:00 The start time of the time range that is specified in the request. The start time can be a UNIX timestamp. The start time can also be a value in the "%Y-%m-%d %H:%M:%S<time_zone>" format, for example: “2018-01-02 12:12:10+8:00”.
--to_time String Yes 2021-06-01 18:18:00+8:00 The end time of the time range that is specified in the request. The end time can be a UNIX timestamp. The end time can also be a value in the "%Y-%m-%d %H:%M:%S<time_zone>" format, for example: “2018-01-02 12:12:10+8:00”.
--batch_size String No 1000 The number of logs to iteratively return for each query.
--compress Boolean No true Specifies whether to compress the returned log data. Valid values:
  • true (default value): The returned log data is compressed.
  • false: The returned log data is not compressed.
For information about the global parameters of the Log Service command-line interface (CLI), see Global variables.

Examples

  • Sample requests
    Use the default account to query log data that is generated within a specified time period. Run the following command:
    aliyunlog log pull_log --project_name="aliyun-test-project" --logstore_name="logstore-a" --shard_id=0 --from_time="2021-06-01 18:15:00+8:00" --to_time="2021-06-01 18:18:00+8:00" --batch_size=1000 --compress=true
  • Sample responses
    {
      "count": 1,
      "logs": [
        {
          "__source__": "203.0.113.217",
          "__tag__:__hostname__": "iZ3****vZ",
          "__tag__:__pack_id__": "5EE3A1C7FF6C8740-1B8",
          "__tag__:__receive_time__": "1622542565",
          "__time__": 1622542562,
          "__topic__": "",
          "activity_id": "",
          "computer_name": "iZ3s****wvZ",
          "event_data": "{\"Binary\":\"4E0065007400530065007400750070005300760063002F0034000000\",\"param1\":\"Network Setup Service\",\"param2\":\"running\"}",
          "event_id": "7036",
          "kernel_time": "0",
          "keywords": "[Classic]",
          "level": "Information",
          "log_name": "System",
          "message": "The Network Setup Service 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": "12303",
          "related_activity_id": "",
          "session_id": "0",
          "source_name": "Service Control Manager",
          "task": "",
          "thread_id": "6652",
          "type": "wineventlog",
          "user_data": "{\"xml_name\":\"\"}",
          "user_time": "0",
          "version": "0"
        }
      ],
      "next_cursor": "MTYxNDc1MDAyNzM3MzI2MDI4NQ=="
    }
    {
      "count": 0,
      "logs": [],
      "next_cursor": "MTYxNDc1MDAyNzM3MzI2MDI4NQ=="
    }