Hi.
I’d like to get commulativeSum of all “read_bytes” of a measurement “all_usage” inside a function
function definition is
consumed = (session) => {
readBytes = from(bucket: “turn”) // Replace “your_bucket” with your InfluxDB bucket name
|> range(start: -2d)
|> filter(fn: (r) => r[“_measurement”] == “all_usage”)
|> filter(fn: (r) => r[“_field”] == “read_bytes”)
|> cumulativeSum(columns: [“read_bytes”])
|> tableFind(fn: (key) => key._field == “read_bytes”)
|> getRecord(idx: 0)
return readBytes.read_bytes
}
and later on I am using this function like:
|> map(fn: (r) => ({ r with
duration: int(v: duration(v: int(v: r._time) - int(v: r.time_seesion_start))),
read_bytes: consumed(session: r.session)
}))
but I get nothing back from the function.
I tried to test the inner code of a function in a flux explorer. But I can’t make yield after getRecord
any ideas what am I doing wrong ?