[英]How to Migrate from MariaDB to InfluxDB Datetime to Time
最近几天,我试图将一些数据从MariaDB导出为InfluxDB格式。
我使用以下语法从MariaDB导出数据:
select CONCAT("insert cpu_load,host=" ,HostName ," value=",
CPUUsedPercentage," ",UNIX_TIMESTAMP(CPUTime))
from monitor.CPUStats;
输出为:
insert cpu_load,host=host1 value=2.85 1696683600
CPUtime数据类型为日期时间,其格式为:
2/11/2017 3:56:18 PM
The output insert statement gets inserted in **InfluxDB** but the queries in **Grafana** or **Telegraf** are not retrieving nothing because of the time formats.
查询可能是:
SELECT mean("value") AS "mean_value" FROM "monitor"."autogen"."cpu_load"
WHERE time > now() - 1h AND "host"='prodvert03' GROUP BY time(10s) FILL(null)
错误信息是:
Your query is syntactically correct but returned no results
所以我确实相信是在时间列格式。 UNIX_TIMESTAMP(CPUTime)不能解决问题。
任何想法或帮助将不胜感激。
谢谢
SELECT AVG(`value`) AS "mean_value"
FROM `monitor`.`autogen`.`cpu_load`
WHERE `time` > NOW() - INTERVAL 1 HOUR
AND `host` = 'prodvert03'
GROUP BY FLOOR(UNIX_TIMESTAMP(`time`) / 10);
会越来越近。 我不知道FILL(null)
是什么意思。
许多不必要的语法差异。
看起来像你的influxdb插入语句
插入cpu_load,host = host1值= 2.85 1696683600
使用自纪元以来的秒数作为时间戳,而influxdb默认使用纳秒级的时间精度afaik。 因此,我怀疑您插入的数据没有以您期望的时间戳存储在influxdb中。
您可能需要在precision <format> specifies the format of the timestamp: rfc3339, h, m, s, ms, u or ns
CLI工具中使用精度设置: precision <format> specifies the format of the timestamp: rfc3339, h, m, s, ms, u or ns
有关详细信息,请参阅InfluxDB文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.