I’m using a query to show data like
from(bucket: "LaboratorioProduzione")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Postazione1")
|> filter(fn: (r) => r["TipoTest"] == "34")
|> filter(fn: (r) => r["_field"] == "contatore M1")
|> aggregateWindow(every: 5s, fn: mean, createEmpty: false)
|> yield(name: "mean")
Now I need to count the time the data goes above a certain value (300)
I can’t understand how to use the stateCount with my actual query
Anaisdg
September 11, 2023, 4:40pm
2
Hello @NicoCaldo ,
I would recommend doing the following:
from(bucket: "LaboratorioProduzione")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Postazione1")
|> filter(fn: (r) => r["TipoTest"] == "34")
|> filter(fn: (r) => r["_field"] == "contatore M1")
|> aggregateWindow(every: 5s, fn: mean, createEmpty: false)
|> filter(fn: (r) => r._value >= 300.0)
|> count()
|> yield(name: "mean")
thanks. The only problem is that with this approch it counts a crazy number of time when, instead, I just need to count the rising fronts. Is there a way to do that?
grant1
September 13, 2023, 12:22am
4
How about this?
from(bucket: "LaboratorioProduzione")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Postazione1")
|> filter(fn: (r) => r["TipoTest"] == "34")
|> filter(fn: (r) => r["_field"] == "contatore M1")
|> aggregateWindow(every: 5s, fn: mean, createEmpty: false)
|> derivative(unit: 1s, nonNegative: true)
|> filter(fn: (r) => r["_value"] > 0)
|> count()
|> yield(name: "mean")