Time since last series data

Hello,
I am looking to identify the time elapsed since the last measurement was recorded for a specific series.
We have a server poll response information added to Influxdb, I am looking to display (query via Grafana), time since last poll response.
Appreciate any suggestion on this query. The poll response time (in seconds) is a field in the measurement.

select poll_resp_time from myseries order by desc limit 1
name: myseries
time                    poll_resp_time
----                    --------------
1492785395626340000     1492785395
1 Like

Sounds like you effectively want to be able to do:

select now()-time,poll_resp_time from myseries order by desc limit 1

As far as I know, that’s not possible, as I discovered in this thread: Shift timestamp returned by SELECT query

I came across this post when trying to solve this in flux. I hacked it together as follows:

import "experimental"

t1 = from(bucket: "telegraf")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "processes")
  |> filter(fn: (r) => r._field == "dead")
  |> last()


t2 = from(bucket: "telegraf")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "processes")
  |> filter(fn: (r) => r._field == "dead")
  |> last()
  |> map(fn: (r) => ({
      r with
      _time: experimental.addDuration(d: 0h, to: now()),

    }))

union(tables: [t1, t2])
|> sort(columns: ["_time"], desc: false)
|> elapsed()