背景:
prometheus默认使用的时间戳是 UTC ,UTC 代表 "协调世界时"(Coordinated Universal Time),是国际标准时间。它是一种基于原子钟的时间标准,被认为是世界上最准确的时间标准
我想做的事情:
修改prometheus程序里的时间修改为 CTS(中国标准时间),"Asia/Shanghai " 时区
我做的修改:
#增加时区挂载 - /etc/localtime:/etc/localtime:ro
问题:
这个挂载只能解决prometheus容器的时间,但是prometheus程序本身的时间并不是使用的容器的本地时间,所以无法解决前端显示和告警时区相差的问题
prometheus官方给出的说明:
Can I change the timezone? Why is everything in UTC?
To avoid any kind of timezone confusion, especially when the so-called daylight saving time is involved, we decided to exclusively use Unix time internally and UTC for display purposes in all components of Prometheus. A carefully done timezone selection could be introduced into the UI. Contributions are welcome. See issue #500 for the current state of this effort.
github 讨论:
https://github.com/prometheus/prometheus/issues/500
怎么解决?
想要校准时区和时间,只能在前端UI或者获取数据之后自行转换,prometheus也是这么做的
标签:UTC,prometheus,说明,Prometheus,时间,timezone,时区 From: https://www.cnblogs.com/Leonardo-li/p/17868260.html