Search code examples
grafana

Grafana Dashboard: bar chart for time series


I am using Postgres data source to get data:

select report_date, name, value from T 
where report_date in ('2023-07-18','2023-07-25')

Here report_date column has type DATE.

I am plotting the Bar chart using transformation: Prepare time-series → Multi-frame time series

The bar chart is displayed, but the x-axis labels are shifted by 1 day back - they are:

                   07/17   and 07/24

How to fix it?


Solution

  • Sounds like a timezone issue. Make sure that the same timezone is used across the database by setting it ti UTC

    SET timezone = 'UTC';
    

    or run the specific query by explicitly setting the time zone for it:

       SELECT report_date, name, value
       FROM T
        WHERE report_date AT TIME ZONE 'UTC' IN ('2023-07-18' AT TIME ZONE 'UTC', '2023-07-25' AT TIME ZONE 'UTC');