Prometheus时区问题说明
背景:
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也是这么做的
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2022-12-01 记一次移动云服务器IP消失的原因