Home > Software engineering >  Grafana shift in time with Postgres
Grafana shift in time with Postgres

Time:11-18

I have a postgres table with timestamp. Postgres is set to CET. Grafana is also set to CET.

In the database I have timestamps up to eg. 2 p.m. What I see in Grafana is only data up to 1 p.m. If I change the timezone, the time axis is changed, but not all data are selected from data base, i.e. the data of last hour is always missing.

What am I doing wrong?

CodePudding user response:

The basic rule is to have data in the DB in the UTC timezone. Grafana queries DB in the UTC timezone and then it will "move" UTC DB result into selected dashboard time zone automatically (usually it is a browser timezone, but timezone can be configured in the dashboard configuration).

Any non UTC timezone for data in DB means problem. Local timezone is also a problem because Daylight Saving Time. Did you think how your data will be saved when there is change CET <-> CEST ? You will have doubled data or missing data for one hour. So golden rule: data in the DB must be saved in the UTC timezone.

  • Related