Flux function fill() with influxdb 1.7.6

flux
#1

I just updated my Influxdb to the latest 1.7.6 version (flux v0.24) and wonderd that the fill() function is not showing up in the FLUX FUNCTIONS dropdown. The does not throw any Error, it just simply does not do anything.

from(bucket: "Export/autogen")  
|> range(start: 2019-00-00T00:00:00Z)  
|> filter(fn: (r) =>
      r._measurement == "Data" and
      r._field == "Value" and
      r.TagId == "23846"
    )   
|> fill(column: "_value", usePrevious: true)
|> yield()

It also does nothing when trying to change the fill() function to just

|> fill(usePrevious: true)

In https://community.influxdata.com/t/flux-fill-function-with-influxdb-1-x/9387 a staff member said that in v1.7.6 the fill function will be available again.

Is there any major mistake inmy code or ist there just a bug?

#2

Hi @Froonsoi, one of our engineers built 1.7.6 from source and fill worked for him. Have you tried using it with this syntax to see what happens?

from(bucket: "telegraf/autogen") |> range(start:-10m) |> filter(fn: (r) => r._measurement == "cpu") |> fill(value: 1.4)

#3

Hi, thanks for the reply.
I tried your syntax but it didn’t work.
It just ignores the fill function, but it catches if there is an error in it.

When I use the InfluxQL with the Query:

SELECT mean("Value") AS "mean_Value" FROM "Export"."autogen"."Data" WHERE time > :dashboardTime: AND "TagId"='23846' GROUP BY time(1m) FILL(previous)

I get my expected behavior.

With Flux:

A = from(bucket: "Export/autogen")  
|> range(start: 2019-01-01)  
|> filter(fn: (r) =>
      r._measurement == "Data" and
      r._field == "Value" and
      r.TagId == "23846"
    )   
  
|> fill(value: 12.0)
|> yield()

It get this:

Any Idea?
Thanks.

#4

Just to cover all our bases, can you run curl -sL -I localhost:8086/ping to check your version number?

#5

There are two things that I’m noticing in your InfluxQL query that are different from your Flux query: you’re using mean and you’re grouping by time. Could that be causing the difference?

#6

Curling gives me following result:

curl

I see your point. I tried to get as close to the InfluxQL Query but mean() and Group by() didnt make a difference

#7

Ok, so i’m very new but also had problems with fill() not wroking.
for some reason this works

from(bucket: "openhab_db")
  |> range(start: -2y, stop: -1y)
  |> filter(fn: (r) => r._measurement == "G_Temperature_wn8_pool" and r._field == "value")
  |> aggregateWindow(every: 3d, fn: mean)
  |> fill(usePrevious: true)  

but this one will come back with a hole in the results:

from(bucket: "openhab_db")
  |> range(start: -2y, stop: -1y)
  |> filter(fn: (r) => r._measurement == "G_Temperature_wn8_pool" and r._field == "value")
  |> fill(usePrevious: true)  
  |> aggregateWindow(every: 3d, fn: mean)

Notice the order when the fill is used

#8

Hi @Maciej_Eckstein, fill(usePrevious: true) will fail if there is a nil value being used as the fill value, and flux will have problems with a calculation that has nil values. The order of fill matters, and you may also have to add a fill with a default value.

#9

@Froonsoi, does removing the mean and groupby from your InfluxQL query yield the same result as your Flux query?

#10

@Sonia_Gupta, yes. I get the exact same query.

#11

I do not exactly understand yourpoint. If you could explain it a bit more.
My pool temp measument has no values in the DB for a about a week. So both query with aggregateWindow(every: 3d, fn: mean) and without has null datapoints. Then fill() should behave similar. However it does not. Same query in th IQL is flawless but there you dont have and issue of order.

#12

@Froonsoi Do you get the expected result which looks like the top graph?

#13

Hello @Maciej_Eckstein,
Can you please share your input and expected output data? In line protocol? Aggregate window can create additional null values which can help explain why order matters. For example if I run

from(bucket: "telegraf/autogen") 
|> range(start:-24h) 
|> filter(fn: (r) => r._measurement == "cpu" 
and r._field == "usage_user" and r.cpu == "cpu-total")

I don’t have any null values so

fill(usePrevious:true)

doesn’t have any effect if I use it immediately after. However now if I do

from(bucket: "telegraf/autogen") 
|> range(start:-24h) 
|> filter(fn: (r) => r._measurement == "cpu" 
and r._field == "usage_user" and r.cpu == "cpu-total") 
|> aggregateWindow(every: 1h, fn: mean)

I’m asking influx to generate a point for usage_user when telegraf wasn’t running and I wasn’t collecting any data, so it will create a null values (probably when I was sleeping and my computer was off). Now if I use fill() it will have an effect.

#14

Hey @Froonsoi. Fill works for me when I do a similar query. Is it possible there are no null values to fill for?

#15

Ok that makes sense. The order is important in Flux becouse the null points are accualy introduced by the agregateWindow(). In my case I had no mesurments for a week. so with the window of 1d or 3d I made null points this way. Fill needs to be next and that works fine.
Some major change of thinking is required to use flux.

#16

@Sonia_Gupta, well no, I get the false result (bottom picture)

@katy, in the Database there are only rising edges of changes. So there is plenty of space which should be filles with values.

#17

@Maciej_Eckstein agreed. It’s not easy for me to wrap my mind around time.