Reputation: 2545
I want to count amount of values that are greater than specific value. Data:
from(bucket: "bucket name")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._value > 35)
|> count()
If there are no values in the processing data range that are greater the specified value than the influx returns nothing (no data).
Upvotes: 5
Views: 4867
Reputation: 348
Issues appeared with float values ,
where a virtual instance not running for a (missing) timeframe
appeared as constantly-cpu-consuming...
Influxdb connects series without 0 ,here a cpu graph with missing timeframes
fill()
only works on integers,aggregateWindow()
finally helpedfrom(bucket: "sys")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "docker_cpu_percent" )
// |> window(every: 5m, period: 5m, createEmpty: true)
|> aggregateWindow(every: 5m, fn: mean, createEmpty: true)
|> map(fn: (r) => ({
r with
_value: if exists r._value then float(v: r._value) * 1.0 else 0.0
})
)
You might refer to
Upvotes: 0
Reputation: 2545
Solution with a little trick...
Instead of filter()
and count()
- need to use map()
and sum()
from(bucket: "bucket name")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> map(fn: (r) => ({ r with _value: if r._value 35 then 1 else 0 }))
|> sum()
Upvotes: 4