Skip to content

Commit

Permalink
add timezone into doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Jan 25, 2018
1 parent 385b054 commit ff2daf0
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions doc/tutorials/tutorial_pull_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ aliyun log list_shards --project_name="p1" --logstore_name="l1" --jmes-filter="m
也可以使用如下`jmes-filter`只展示数字:

```shell
aliyun log list_shards --project_name="p1" --logstore_name="l1" --jmes-filter="join(' ', map(&to_string(shardID), @))"
aliyun log list_shards --project_name="p1" --logstore_name="l1" --jmes-filter="join(',', map(&to_string(shardID), @))"
```

输出:
Expand All @@ -41,10 +41,10 @@ aliyun log list_shards --project_name="p1" --logstore_name="l1" --jmes-filter="j
根据游标获取数据, 需要传入分区. 下面例子消费分区`3`某个时间范围收集到的数据.

```shell
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00" --to_time="2018-01-24 17:00:00"
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00 CST" --to_time="2018-01-24 17:00:00 CST"
```

这里拉取从时间`2018-01-24 16:00:00``2018-01-24 17:00:00`在分区`3`中的所有数据, 例如:
这里拉取从时间`2018-01-24 16:00:00 CST``2018-01-24 17:00:00 CST`在分区`3`中的所有数据, 例如:
```shell
{"count": 101, "logs": [{"k1":"a1", "k2":"a2"}, {"k1":"b1", "k2":"b2"}, ... ]}
```
Expand All @@ -55,7 +55,7 @@ aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from
例如:

```shell
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00" --to_time="2018-01-24 17:00:00" --jmes-filter="join('\n', map(&to_string(@), @))" >> ~/Desktop/test.data
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00 CST" --to_time="2018-01-24 17:00:00 CST" --jmes-filter="join('\n', map(&to_string(@), @))" >> ~/Desktop/test.data
```

输出将被存储在文件`test.data`中, 格式为:
Expand All @@ -66,12 +66,17 @@ aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from
...
```

## 时间格式
时间格式推荐是`%Y-%m-%d %H:%M:%S %Z`, 如`2018-01-24 17:00:00 CST`, 但也支持其他合法的时间格式, 例如:`Jan 01 2018 10:10:10 CST`


## 时间范围
命令`pull_log`传入的时间范围, 需要注意几点:

1. 这里的时间指的是服务器接受日志的时间

2. 时间的范围是做闭右开, 上面例子中`16:00:00`服务器接受到的日志会被拉取到, 但是`17:00:00`服务器所接受到的日志不会.
2. 时间的范围是左闭右开`[)`, 上面例子中`16:00:00`服务器接受到的日志会被拉取到, 但是`17:00:00`服务器所接受到的日志不会.



## 特殊的时间范围
Expand All @@ -80,19 +85,19 @@ aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from
特殊游标包括`begin``end`. 例如:

```shell
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="begin" --to_time="2018-01-24 17:00:00"
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="begin" --to_time="2018-01-24 17:00:00 CST"
```

这里拉取所有`2018-01-24 17:00:00`之前服务器接收到的日志.
这里拉取所有`2018-01-24 17:00:00 CST`之前服务器接收到的日志.


又例如:

```shell
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 17:00:00" --to_time="end"
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 17:00:00 CST" --to_time="end"
```

这里拉取所有`2018-01-24 17:00:00`开始及之后服务器接收到的日志.
这里拉取所有`2018-01-24 17:00:00 CST`开始及之后服务器接收到的日志.


## 大数据量
Expand All @@ -107,7 +112,7 @@ aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from

这种情况下, 使用`jmes-filter`的话会针对每一块的输出内容. 也就是上面2块内容分别应用`jmes-filter`来处理. 例如:
```shell
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00" --to_time="2018-01-24 17:00:00" --jmes-filter="join('\n', map(&to_string(@), @))"
aliyun log pull_log --project_name="p1" --logstore_name="l1" --shard_id=3 --from_time="2018-01-24 16:00:00 CST" --to_time="2018-01-24 17:00:00 CST" --jmes-filter="join('\n', map(&to_string(@), @))"
```

输出:
Expand Down

0 comments on commit ff2daf0

Please sign in to comment.