Here’s a bit more insight on what I am trying to accomplish. I am creating threshold checks for various metrics. As of right now this is what I use :
data =
from(bucket: “telemetry”)
|> range(start: -30m)
|> filter(fn: (r) => r[“_measurement”] == “bacnet”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> filter(fn: (r) => r[“deviceInstance”] == “213003”)
|> filter(fn: (r) => r[“network”] == “0”)
|> filter(fn: (r) => r[“objectId”] == “OBJECT_ANALOG_VALUE:0”)
|> last()option task = {name: “2345”, every: 5s}
check = {_check_id: “0b18ff8b54569000”, _check_name: “My Check”, _type: “threshold”, tags: {}}
crit = (r) => r[“value”] > 2.0
ok = (r) => r[“value”] < 2.0
messageFn = (r) => “Check: ${ r._check_name } is: ${ r._level }”data
|> v1"fieldsAsCols"
|> monitor[“check”](data: check, messageFn: messageFn, crit: crit, ok: ok)
It works fine for most use cases… If some metric is over 2.0 (in that example) that check is we get an alarm and every one is happy.
But a use case that this does not cover is delayed alarm. What I mean by that is I want the check to become critical only if the threshold has been consistently breached for more than 5 minutes (or more)
My idea was to modify it this way :
data =
from(bucket: “telemetry”)
|> range(start: -5m)
|> filter(fn: (r) => r[“_measurement”] == “bacnet”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> filter(fn: (r) => r[“deviceInstance”] == “213003”)
|> filter(fn: (r) => r[“network”] == “0”)
|> filter(fn: (r) => r[“objectId”] == “OBJECT_ANALOG_VALUE:0”)option task = {name: “2345”, every: 5s}
check = {_check_id: “0b18ff8b54569000”, _check_name: “My Check”, _type: “threshold”, tags: {}}
// LINQ style representation of what I try to accomplish
crit = (r) => r.all( (r) => r.[“value”] > 2.0 // True if all of the queried data exceeds 2.0
ok = (r) => r.any( (r) => r.[“value”] < 2.0 // True if any of the queried data is lower than 2.0
messageFn = (r) => “Check: ${ r._check_name } is: ${ r._level }”data
|> v1"fieldsAsCols"
|> monitor[“check”](data: check, messageFn: messageFn, crit: crit, ok: ok)
But alas, the world seems to be devoid of any and all that could solve this quandary. The great lords of Influx, with their magical powers, could perhaps provide a solution.
Thanks!