Timeseries graph not showing point with correct X axis time value

  • What Grafana version and what operating system are you using?
  • Grafana V9.2 in Official docker container.
  • Windows 10
  • Chrome browser
  • What are you trying to achieve?
    Using the GraphQL plugin I am pulling timeseries data into Grafana. The table after the Graphql query is correctly filled with the correct timerange. The timestamps in the table are all local time, but the query is done with UTC time. I would like to correctly display the queried data in the timeseries graph.

  • How are you trying to achieve it?
    Using grapql plugin to pull in data.

  • What happened?
    Everything is going well except that the graph is showing the data with the incorrect time values on the x-axis.

In the screenshot below you can see that the data point has an associated time of 16:10:05 (local time) which is correct but the X value in the graph is with one hour offset.

  • What did you expect to happen?
    Correctly graphing of the data as it is populated in the table.

grafana requires all of your datetime be UTC to plot accurarely. What is your data source?

The raw data, as seen in the query inspector window, from the data source (graphql) is correctly ISO8601 UTC timestamped (offset 0). For example: “2022-12-28T20:25:37.706814+00:00”.

image

The data associated with this timestamp then shows up in the table view with the local timestamp (UTC+1).

1 Like

is your localtime UTC? Again what is your data source?

What do you mean with datasource: its a graphql interface on top of I presume a sql database but I am not sure.

1 Like

ahh I am blind. so you say the timestamps in the table, are you referring to the table that results from the graphql query?

Also ISO8601 is a formatting standard not a timezone indicator hence why you still see it local and not UTC

Hi Yosiaz,

  • The raw response data from the query is with UTC offset.
  • The table (second screenshot) is converted to local time
  • The datapoint popup in the first screenshot is also local time (16:10:05) but most important the X-axis value corresponding to that same point is 15:10. Please see the first screenshot.
  • The time series time zone option for the X-axis is set to default, which is UTC+1.

Thanks for all your help!.

I posted a question about the exact same issue just yesterday. I am pulling data from an MSSQL db and have tried modifying the datetime being returned using select mydate as dt at time zone ‘UTC’ so I’m fairly confident that SQL is returning a binary time value ‘based’ on UTC.

Any idea how how to diagnose what grafana is receiving, or rather what SQL server is sending?

So try this out in SSMS

select getdate() at time zone 'UTC' as A, getdate() as B, GETUTCDATE() as C

Which of the dates is true UTC?

Didn’t know that function existed. Very handy.

A and B are equal, C is one hour behind. A seems to imply that SQL server doesn’t do any +1 -1 offsetting when you add the ‘at time zone utc’, so I’m not sure what it does do.
I’m going to have to sit down and play with the functions in SQL and try and work out what I need to do so whatever I end up doing doesn’t go wrong after the next summer time adjustment.

Maybe Grafana needs a wiki type page for each data source type so we can add gotchas when feeding it from different sources.

there is no gotchas. it works the same for all datasources (as it should, it does not vary per data source, that would be a nightmware) the time you use has to be proper UTC.

By gotchas, I mean stuff that you know and think is obvious as you are familiar with doing this all day, but things us mere mortals get caught out on.
Much of the documentation on grafana is written for people who are already working with data in the correct format. Those of us who have to write a query to pull some bit of data out of a db just end up staring at a config trying to work out what on earth it is that grafana is looking for when something isn’t working. Date formats are a good example. I’ve been using grafana for a few years, but I had never had to display hourly data until recently, which is when this problem turned up. Group by date has been good enough until now.

1 Like

We all been there. Remember grafana is a visualization tool, grouping helpers are provided with it by I never use them because they just are short cuts that create generatee code under the hood. I use pure sql functions and aggregators such as group by. So any group by day hour minute or whatever is a task of the database. So if you tighten up your sql coding skills then the rest on grafana aide is easy presentation

Eventually woth this great forum and large army of kind people you will get to where you need. Keep plowing

@yosiasz, have you been able to review my last post as I am still not sure why the popup time value does not match the X-axis time value as shown in the first screenshot of this post.

Changed dashboard timezone to UTC, this seems to fix the issue as in the datapoints are correctly aligned with the X-axis time value.

1 Like