我正在加入 influx 以获得间隔的第一个和最后一个值,然后得到差异。
Preset = 600
FirstValues = from(bucket: "Historian/oneday")
|> range(start: dashboardTime)
|> filter(fn: (r) =>
r._measurement == "TestMeasurement" and
r._field =="Value" and
r.Loc=="TXS"
)
|>window(every:15m)
|>first()
LastValues = from(bucket: "Historian/oneday")
|> range(start: dashboardTime)
|> filter(fn: (r) =>
r._measurement == "TestMeasurement" and
r._field =="Value" and
r.Loc=="TXS"
)
|>window(every:15m)
|>last()
CombinedValues = join (
tables:{first:FirstValues,last:LastValues},
on:["_stop","_start"]
)
totaliser = CombinedValues
|>map(fn: (r) => ({
_time: r._start,
//Want to do this, r._value_first < r._value_last ? Preset : r._value_first
_value: r._value_first - r._value_last
}))
totaliser
|>window(every:inf)
这工作正常,直到时间差返回一个正数。
但是,如果 join 返回的第一个值小于 2nd value ,我想用 perset 值更新它。
前任:
Preset = 600
totaliser = CombinedValues
|>map(fn: (r) => ({
_time: r._start,
//Want to do this, r._value_first < r._value_last ? Preset : r._value_first
_value: r._value_first - r._value_last
}))