Get the timestamp from datapoint and use that as the start range in a different query

  • What Grafana version and what operating system are you using?
    Grafana 9.0.3 desktop.

  • What are you trying to achieve?
    I try to make a gauge progression bar of a charged battery status

  • How are you trying to achieve it?

I use influxdb as datasource. I know in advance what the amount of kWh is that the battery should reach, this is my maximum value and I get I from my datasource. What I don’t have is the charged amount of energy in the battery. I tried to start measuring the amount of kWh the battery gets from the moment is starts to charge, the time it starts to charge is the time I receive the first datapoint.

  • What happened?

The problem is that I do not know how I can get the time stamp from the first data point, and then use that time stamp as my starting time to start measuring the kWh of the battery in a different query . I do not now if this is even possible in Grafana. Thanks in advance

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

from(bucket: “EVScheduler”)
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r[“_measurement”] == “Website” and r._field == “DesiredParkingTime”)
|> keep(columns: [“_time”, “_value”] )
|> last()

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

no

  • Did you follow any online instructions? If so, what is the URL?