Since moving from TickScripts in V1 to Flux v2.6 im struggling with some of the functions.
The below i want to add the critical duration to my alert notification but it just fails.
Have i missed something silly?
FYI - The below is my version of an SNMP bandwidth check and alert.
import “influxdata/influxdb/monitor”
import “influxdata/influxdb/v1”data =
from(bucket: “telegraf”)
|> range(start: -5m)
|> filter(fn: (r) => r[“_measurement”] == “cr01ma4” or r[“_measurement”] == “xs01ma04”)
|> filter(fn: (r) => r[“ifName”] == “Ethernet1/47”)
|> filter(fn: (r) => r[“_field”] == “ifHCInOctets”)
|> derivative(unit: 1s, nonNegative: true)
|> map(fn: (r) => ({r with _value: float(v: r._value) * 8.0 / 1000000.0}))option task = {name: “WDWM MA4 ↔ TN19”, every: 5m, offset: 0s}
check = {
_check_id: “0b2c2a6ddfab4000”,
_check_name: "“WDWM MA4 ↔ TN19”,
_type: “threshold”,
tags: {},
}
crit = (r) => r[“ifHCInOctets”] < 50.0 or r[“ifHCInOctets”] > 9000.0
messageFn = (r) =>
“Check: ${r._check_name} is: ${r._level} Outside of threshold 50 Mbps - 9000 Mbps. State duration: ${string(v: r._value)} minutes.”data
|> v1"fieldsAsCols"
|> monitor[“check”](data: check, messageFn: messageFn, crit: crit)
|> monitor[“stateDuration”](unit: 1m)