mysql如何按周期查詢,grafana默認(rèn)時(shí)區(qū)設(shè)置?
mysql 設(shè)置 time_zone 為 "+8:00" 沒(méi)問(wèn)題,grafana 的時(shí)區(qū)也設(shè)置為UTC+8:00也沒(méi)問(wèn)題。
mysql 表中存儲(chǔ)的日期正常,但 grafanfa 讀到的數(shù)據(jù)卻快了 8 小時(shí)。
?
解決辦法給時(shí)間字段加 UNIX_TIMESTAMP() 方法,如將
SELECT
created_at AS "time",
metric AS metric,
value
FROM test
WHERE
$__timeFilter(created_at)
ORDER BY created_at
修改為
SELECT
UNIX_TIMESTAMP(created_at) AS "time",
metric AS metric,
value
FROM test
WHERE
$__timeFilter(created_at)
ORDER BY created_at