Need last Flux 0.65 histogram bucket to be ‘inf’

Documentation (without using helper function)

  |> histogram(bins: [0.0, 10.0, 20.0, 30.0])

What;s the correct syntax to include bin for everything > than last value?

This doesn’t appear to be currently possible. I’ve created an issue for this here:

Until that issue is worked on, you can work around it by specifying a high final bin or, if you want to be more careful, you can do this:

import "math"
max_value = 1000.0
|> map(fn: (r) => ({r with _value: math.min(x: r._value, y: max_value)}))
|> histogram(bins: [0.0, 10.0, 20.0, 30.0, max_value])

That will prevent the number from being above the highest bin.

1 Like

I took a further look and there’s also the linearBins function which might help. You can use that function to generate the bins like this: linearBins(start: 0.0, width: 10.0, count: 4) which would generate your specific buckets.

1 Like

my desired bins are not even close to linear…they are very specific to my use-case, but i thought having last bucket more elegantly +inf was better than having to rip through the series to grab the max_value

Thanks for responding. We now have the issue above for allowing someone to specify +Inf instead of relying on the linearBins function. For now, the workaround is probably the easiest way to get this working now, but I understand that usability is important and the convenience of specifying inf is definitely something we want to have in there.