调用CLI命令获取指定时间段的日志详细信息。
请求语法
aliyunlog log pull_log --project_name= --logstore_name= --shard_id= --from_time= --to_time= [--batch_size=] [--compress=] [--access-id=] [--access-key=] [--sts-token=] [--region-endpoint=] [--client-name=] [--jmes-filter=] [--format-output=] [--decode-output=]
请求参数
该命令的必选和特有参数描述如下。
参数名称 | 数值类型 | 是否必选 | 示例值 | 描述 |
–project_name | String | 是 | aliyun-test-project | Project名称。 |
–logstore_name | String | 是 | logstore-a | Logstore名称。 |
–shard_id | Integer | 是 | 0 | Shard ID。 |
–from_time | String | 是 | 2021-06-01 18:15:00+8:00 | 开始时间,Unix时间戳格式或者“%Y-%m-%d %H:%M:%S” 格式,例如“2018-01-02 12:12:10+8:00” 。 |
–to_time | String | 是 | 2021-06-01 18:18:00+8:00 | 结束时间,Unix时间戳格式或者“%Y-%m-%d %H:%M:%S” ,例如“2018-01-02 12:12:10+8:00” 。 |
–batch_size | String | 否 | 1000 | 每个查询迭代获取的日志数据数量。 |
–compress | Boolean | 否 | true | 是否压缩返回日志数据。
|
关于该命令的全局参数,请参见全局参数。
示例
- 请求示例使用默认账号查询指定时间段内的日志数据。命令示例如下:
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
- 返回示例
{ "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=="}
更多信息,请参见使用CLI的常见问题。
内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家
阿里云企业补贴进行中: 马上申请
腾讯云限时活动1折起,即将结束: 马上收藏
同尘科技为腾讯云授权服务中心。
购买腾讯云产品享受折上折,更有现金返利:同意关联,立享优惠
转转请注明出处:https://www.yunxiaoer.com/160487.html