When I run the follow command it inserts it into the database an hour in the future even though the time from the python prompt “str(datetime.datetime.now())” says the correct time. The python script is run on a Raspberry PI and I’m viewing the data through Grafana via a web browser from a Windows PC. Grafana is installed on the pi.
This is the code im writing:
data = [{“measurement”: “AirParticles”,
“tags”: {
“Location”:“living_room”,
“Floor”: “1st_Floor”
},
“time”: str(datetime.datetime.now()),
“fields”: {
“03um” : gr03um_average
}
}
]
client.write_points(data)
Is it a time zone problem?
Maybe. But I cant figure out where the problem is coming from? any ideas on to figure this out.
i type into influxdb “SHOW DIAGNOSTICS” and this is what it showed
PID |
currentTime |
started |
uptime |
465 |
“2018-10-07T16:09:38.381746869Z” |
“2018-10-06T16:52:37.696629892Z” |
“23h17m0.685119425s” |
which is the an hour different to the linux command “date”
Sun 7 Oct 17:09:38 BST 2018. ones showing BST and the other is UTC i guess? how does influx interpret this date?
Thanks
solved it, just replaced the line “time”: str(datetime.datetime.now())" with ““time”: str(datetime.datetime.utcnow())”
The key inforamtion i was missing was influx requires the time in utc which makes sense.