I have telegraf ping input and send the result to influx2.7. I am trying to setup the alert meanwhile to send it to pagerduty to trigger the phone call.
I see the procedure is to create the check, setup the threshold, select the notification endpoints and rules.
Everything is done so far. But it’s not working as expected. The check failed, there is no status or notification created inside _montioring bucket. Based on the log from the _task, it shows unsupported input type for mean aggregate: string
I believe when the ping result is written to the bucket. I tried a few based on the readings, to have offset to avoid the read/write conflict, it doesn’t really help.
I also tried to convert the string to float but the same result.
The following is what i have, can you help me out?
import “influxdata/influxdb/monitor”
import “influxdata/influxdb/v1”
data =
from(bucket: “telegraf”)
|> range(start: -1m)
|> filter(fn: (r) => r[“url”] == “10.25.74.168”)
|> filter(fn: (r) => r[“_field”] == “percent_packet_loss”)
|> map(fn: (r) => ({r with “_value”: float(v: r[“_value”])}))
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
option task = {name: “Packet Loss”, every: 1m, offset: 15s}
check = {_check_id: “0b371ffd76a1f000”, _check_name: “Packet Loss”, _type: “threshold”, tags: {}}
crit = (r) => r[“percent_packet_loss”] > 20.0
messageFn = (r) => “Check: ${r._check_name} is: ${r._level}”
data |> v1"fieldsAsCols" |> monitor[“check”](data: check, messageFn: messageFn, crit: crit)