kube-prometheus项目中,默认dashboard时区是UTC,比中国时间慢了8小时,很不便于日常监控查看,如下图
1.搜索timezone关键字眼
grep -i timezone grafana-dashboardDefinitions.yaml
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "browser",
"timezone": "utc",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
"timezone": "UTC",
2.sed命令直接修改,调整时间utc为utc+8
sed -i 's/UTC/UTC+8/g' grafana-dashboardDefinitions.yaml
sed -i 's/utc/utc+8/g' grafana-dashboardDefinitions.yaml
grep -i timezone grafana-dashboardDefinitions.yaml
"timezone": "utc+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "utc+8",
"timezone": "utc+8",
"timezone": "utc+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "browser",
"timezone": "utc+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
"timezone": "UTC+8",
kubectl apply -f grafana-dashboardDefinitions.yaml # 使修改的配置生效
>F5刷新页面,再次查看,可以看到所有相关的dashboard显示时间已自动+8,变成了北京时间,比较符合国人习惯
标签:utc,UTC,grafana,yaml,prometheus,dashboard,timezone,dashboardDefinitions
From: https://www.cnblogs.com/khtt/p/17599651.html