Is there a way to fill a result of sparse data with 0 value points with Flux?

Viewed 2285

I have points spread out every 5 min, and when the value is 0 the point is just omitted. I'd like to fill the omitted data with empty values.

I see with InfluxQL I could do:

group by time(5m) fill(0)

But I am using InfluxDB 2. I have tried this query:

      from(bucket:"%v")
         |> range(start: %d) 
         |> filter(fn: (r) => r._measurement == "volume" and r.id == "%v")
         |> window(every: 5m, period: 5m, createEmpty: true)
         |> fill(value: 0)

But it does not appear to be working.

Any help is appreciated.

2 Answers

The fill() function only replaces nulls in the data and not missing data points based on time. At the moment there's no function available to this time, although one has been requested.

What I've done over time periods where I need to fill in missing data is to generate a time series (with zero values) and join this with the time series with missing data.

Related