I have some simple time series data, and I’d like to create daily aggregates for the whole of last year via the histogram
function, so that for every day I store the count of samples in each histogram bin.
Then I should be able to use the histogramQuantile
function to calculate historical quantiles.
I can write the query easily enough to generate the histograms:
from(bucket: "B1")
|> range(start: 2024-01-01T00:00:00Z, stop: 2025-01-01T00:00:00Z)
|> window(every: 1d)
|> histogram(
bins: [
0.,
1.,
2.,
3.,
999.,
],
This produces a result set with _start
, _stop
, _field
, _value
, and le
columns, where _value
is the bin count and le
is the upper bound of each bin. This is all good.
But when i put this in a task, piped into the to()
function to store the data in another bucket, I cannot get it to include the le
column.
|> map(fn: (r) => ({r with _time: r._start}))
|> to(
bucket: "B1daily",
fieldFn: (r) => ({"_value": r._value, "le": r.le}),
org: "MYORG",
)
I’ve tried with and without the fieldFn
, but whatever do I cannot get le
to be stored in my target bucket.
I’m probably missing something simple about how numeric columns work in Influx.