Queries the details of logs that are generated within a specified 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 required parameters of this command and parameters that are specific to this 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 beginning of the time range to query. Specify the value as a UNIX timestamp or in the |
--to_time | String | Yes | 2021-06-01 18:18:00+8:00 | The end of the time range to query. Specify the value as a UNIX timestamp or in the |
--batch_size | String | No | 1000 | The number of logs that are returned for each query. |
--compress | Boolean | No | true | Specifies whether to compress the returned logs. Valid values:
|
For more information about the global parameters of this command, see Global parameters.
Examples
Sample requests
Use the default account to query logs that are generated within a specified time range:
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
Sample responses
{ "count": 2, "logs": [ { "__source__": "127.0.0.1", "__tag__:__receive_time__": "1677723529", "__time__": 1677723524, "__topic__": "nginx_access_log", "body_bytes_sent": "1977", "host": "www.example.com", "http_referer": "www.example.com", "http_user_agent": "Mozilla/4.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/11.0.1245.0 Safari/537.36", "http_x_forwarded_for": "47.100.XX.XX", "remote_addr": "47.100.XX.XX", "remote_user": "_s0z", "request_length": "2275", "request_method": "POST", "request_time": "39", "request_uri": "/request/path-1/file-2", "status": "200", "time_local": "02/Mar/2023:02:18:44", "upstream_response_time": "0.08" }, { "__source__": "127.0.0.1", "__tag__:__receive_time__": "1677723529", "__time__": 1677723524, "__topic__": "nginx_access_log", "body_bytes_sent": "1315", "host": "www.example.com", "http_referer": "www.example.com", "http_user_agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.814.0 Safari/535.1", "http_x_forwarded_for": "47.100.XX.XX", "remote_addr": "47.100.XX.XX", "remote_user": "6be", "request_length": "2851", "request_method": "POST", "request_time": "16", "request_uri": "/request/path-3/file-7", "status": "200", "time_local": "02/Mar/2023:02:18:44", "upstream_response_time": "0.54" } ], "next_cursor": "MTY3Mzg2Mzc2OTk0MDQyNDc5NA==" } { "count": 0, "logs": [], "next_cursor": "MTY3Mzg2Mzc2OTk0MDQyNDc5NA==" }
For more information, see FAQ about using Simple Log Service CLI.