Skip to content

Commit

Permalink
some comments about timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
chenryn committed Feb 2, 2015
1 parent 1c407ad commit 6247733
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions filter/date.md
Expand Up @@ -76,3 +76,15 @@ filter {
```

**注意:时区偏移量只需要用一个字母 `Z` 即可。**

## 时区问题的解释

很多中国用户经常提一个问题:为什么 @timestamp 比我们早了 8 个小时?怎么修改成北京时间?

其实,Elasticsearch 内部,对时间类型字段,是**统一采用 UTC 时间,存成 long 长整形数据的**!对日志统一采用 UTC 时间存储,是国际安全/运维界的一个通识——欧美公司的服务器普遍广泛分布在多个时区里——不像中国,地域横跨五个时区却只用北京时间。

对于页面查看,ELK 的解决方案是在 Kibana 上,读取浏览器的当前时区,然后在页面上转换时间内容的**显示**

所以,建议大家接受这种设定。否则,即便你用 `.getLocalTime` 修改,也还要面临在 Kibana 上反过去修改,以及 Elasticsearch 原有的 `["now-1h" TO "now"]` 这种方便的搜索语句无法正常使用的尴尬。

以上,请读者自行斟酌。

0 comments on commit 6247733

Please sign in to comment.