I try to run influxdb as a Docker container. I am using docker-compose for that:
influxdb:
image: influxdb:1.7.7-alpine
ports:
- "8083:8083"
- "8086:8086"
- "8090:8090"
volumes:
- ./influxdb-data:/var/lib/influxdb
networks:
- mynet
expose:
- "8086"
environment:
TZ: Europe/Prague
The problem is the timezone. I don't know how to start InfluxDB in my local timezone, here you can see the problem:
[michal@motoko ~]$ LC_ALL=C date
Fri Aug 23 07:38:44 CEST 2019
[michal@motoko ~]$ LC_ALL=C influx -host 'localhost'
Connected to http://localhost:8086 version 1.7.7
InfluxDB shell version: 1.7.7
> use test Using database test
> insert test value=4
> precision rfc3339
> select * from test
name: test
time value
---- ----
2019-08-23T05:39:09.017460215Z 4
>
As you can see (correct) real time at my machine is "07:38:44" while timestamp stored in database is "05:39:09". I am in UTC+2 timezone.
Can InfluxDB in Docker run in my local timezone? I've tried to set TZ
variable but InfluxDB probably needs /etc/timezone
. I haven't found InfluxDB configuration parameter for that.
Or do I need to use tz()
in every query? This works correctly:
> select * from test tz('Europe/Prague')
name: test
time value
---- -----
2019-08-23T07:39:09.017460215+02:00 4
As mentioned on the comments, InfluxDB timezone is immutable by default. But as you mentioned, you can set your timezone using tz() command.
A possible solution is store your timezone on InfluxDB and use it within your queries.