我有带测量的influxdb数据库test:
name: mes1
time Amount Buy_order_id Price
---- ------ ------------ -----
1529832177822 0.02294 132868375 130117.83 我想用Grafana制作图表,但所有数据都是1970年的。我还有其他的测量方法:
name: cpu_load_short
time Bool_value Float_value Int_value String_value host region
---- ---------- ----------- --------- ------------ ---- ------
1257894000000000000 true 0.64 3 Text server01 us-west这一次可以正常工作。我发现,测量cpu_load_short中的时间是以ns为单位存储的,但是测量mes1中的数据是以ms为单位存储的。
我从websocket接收mes1的时间。cpu_load_short的时间是由python生成的:
datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')所有数据都通过influxdb-python发送到influxdb。我尝试调整mes1的时间,并在number的末尾添加六个零:
'1529832177822' -> '1529832177822000000'但我收到了:
OverflowError: signed integer is greater than maximum如何将数据发送到influxdb并从中生成图形,以便数据具有正确的格式和正确的日期?也许我遗漏了一些东西,但是我不明白为什么我不能用ns发送数据到我的数据库,但是我可以用datetime发送它。谁能给我解释一下,问题出在哪里?
发布于 2018-07-03 17:53:36
我也遇到过同样的问题,并且能够解决,让我试着指导你。
当您使用influxdb-python客户端将点写入InfluxDB时,您可以在write_points方法中指定时间精度。(http://influxdb-python.readthedocs.io/en/latest/api-documentation.html#influxdb.DataFrameClient.write_points)
举个例子:
from influxdb import InfluxDBClient
client = InfluxDBClient(host=host, port=port, database=database)
client.write_points(value, time_precision='ms')这将为您将您的ms转换为ns。希望这能有所帮助。
https://stackoverflow.com/questions/51014779
复制相似问题