6

I have influxdb database test with measurement:

name: mes1
time          Amount     Buy_order_id Price     
----          ------     ------------ -----     
1529832177822 0.02294    132868375    130117.83 

I would like to make graph in Grafana, but all data are in year 1970. I have other measurement:

name: cpu_load_short
time                Bool_value Float_value Int_value String_value host     region
----                ---------- ----------- --------- ------------ ----     ------
1257894000000000000 true       0.64        3         Text         server01 us-west

This time works fine. I figure out, that time in measurement cpu_load_short are stored in ns, but data in measurement mes1 are stored in ms.

I receiveing time for mes1 from websocket. Time for cpu_load_short is generated from python:

datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')

All data are sent to influxdb via influxdb-python. I tried to adjust time for mes1 and add six zeros in the end of number:

'1529832177822' -> '1529832177822000000'

but I received:

OverflowError: signed integer is greater than maximum

How can I send data to influxdb and make graph from it, so the data will be in proper format and the right date? Maybe I missing something but I can't figure out why I cant send data to my database in ns but I can send it with datetime. Could anybody explain me, where is the problem?

4

1 回答 1

3

我遇到了同样的问题并且能够解决它,让我尝试指导您。

当您使用 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')

这将为您转换msns。希望这可以帮助。

于 2018-07-03T09:53:36.400 回答