Data hole detection

I am stumped trying to figure out how to do this. I have measurement data from 1000s of sensors (each sensor ID is a tag). These measurements are done every hour. What I need to do is to detect if there are any “holes” in the data. I.e. maybe between jan 10 and 20 sensor A123 stopped emitting data and now there is a data hole for that sensor.

My current train of thought is to convert the timestamp to unix seconds as a new column and then do a difference with the previous value. But I have not found the way to express this in flux. Note I need to be able to do this across millions of data points so taking each point individually and going back and finding the last value seems like a dead end to me.

Any ideas? Is there a function I’m overlooking? I’d love to have access to the previous record in Flux so I can perform a simple math operation.

Answering my own question:

  |> elapsed(unit: 1h)
  |> filter(fn: (r) => r["elapsed"] > 1)