Influxdb vs grafana: delayed results

Hi everyone!

I am experiencing a delay in the query results in Grafana. The values shown in Grafana are about 90 seconds delayed compared to the values in InfluxDB.

I used the same query in both applications. The duration and refresh times are exactly the same. I didn’t apply any transformations, the query is fairly simple, and I didn’t apply any aggregation.

Can someone explain why this is happening? How can I shorten the delay?

Here is a screenshot showing the situation:

Here is the query:

influxdb

from(bucket: "Stromzaehler")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Z1")
  |> filter(fn: (r) => r["_field"] == "16_7_0_Leistung")
  //|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> keep(columns: ["_time", "_value"])
  |> tail(n: 5)
  |> yield(name: "mean")

And here are the query options (the automatic setting, I didn’t change it manually):

Thank you all!

Hi @platinum83

I know this is not your question, but can you explain why the values (not the timestamps) in Grafana are so different vs. the values in InfluxDB? It would indicate that some mathematical operation was used?

Hi Grant2,

The values are consistent in InfluxDB and Grafana. I’m measuring my home’s power consumption, and I turned on the water boiler to observe the delay.

Here are the last 20 results:

I’m performing some calculations in Grafana on other dashboards. I don’t believe these are causing the system to slow down, but I’m eager to test it. Is there a way to stop all other queries in Grafana?

Thanks and best regards,

Did you sync your local OS times everywhere?

Hi Jangaraj,

Grafana and InfluxDB both run on the same Raspberry Pi. I assume that both applications (InfluxDB and Grafana) automatically have the same OS time. Or am I wrong?

Thank you!

Everywhere:

  • source: where the metric is generated - maybe metric timestamp is already ingested with some time drift
  • server: that’s your RPI
  • browser: that OS, where browser is running has also own time, which can be used as “NOW” in Grafana query

Make sure all these “everywhere” have synced times (so they show the same UTC time at the same time). It looks like there can be some time drift somwhere, which can be causing a problem. Of course I don’t have access to your systems, so only you can verify that and prove me that I’m correct/wrong. Pls do that.

Hi Jangaraj,

Thank you for the hint. I found a mismatch in the time settings between the Raspberry Pi and the Windows system with the browser. I corrected it, and now it works. Thank you!

However, I still find it strange that Grafana takes the time from the browser and not from the system where it is running…

But now everything works for me.

Thanks again.