Hi,
I am trying to create a task to send alerts to msteams but this is not working and I am having a hard time to figure it out the reason.
I have the following script
import "contrib/sranka/teams"
option task = {name: "Status Check", every: 1m}
data = from(bucket: "telegraf-unstable")
|> range(start: -1m)
|> filter(fn: (r) => r["_measurement"] == "fccstatus" and r["_field"] == "status" and r["_value"] < 1)
data
|> group(columns: ["host"])
|> map(fn: (r) => ({
_time: r._time,
_value: r._value,
host: r.host,
title: "FCC Status",
text: "FCC ${r.host} status is Down",
summary: "FCC status is ${r._value}",
}))
|> yield(name: "status_below_1")
|> map(fn: (r) => teams.message(
url: "https://myteams-webhook",
title: r.title,
text: r.text,
summary: r.summary
))
this query should return all nodes with status down what means they have value=0 in the field status.
But I can’t even insert this query without influx just almost crash so I have tried to create a proper query using the alert option.
import "influxdata/influxdb/monitor"
import "influxdata/influxdb/v1"
data =
from(bucket: "telegraf-unstable")
|> range(start: -1m)
|> filter(fn: (r) => r["_measurement"] == "fccstatus")
|> filter(fn: (r) => r["_field"] == "status")
|> aggregateWindow(every: 1m, fn: last, createEmpty: false)
option task = {name: "Name this Check", every: 1m, offset: 0s}
check = {_check_id: "0c037f01b7a1d000", _check_name: "Name this Check", _type: "threshold", tags: {}}
crit = (r) => r["status"] < 1.0
messageFn = (r) => "Check: ${ r._check_name } is: ${ r._level }"
data |> v1["fieldsAsCols"]() |> monitor["check"](data: check, messageFn: messageFn, crit: crit)
But this query fails everytime it says Completed(failed).
Any idea how I can just retrieve the nodes with status=0 and send the alert through teams for the nodes that are down?
Details:
Influxdb was deployed through the helm chart influxdb2
apiVersion: v2
appVersion: 2.3.0
name: influxdb2
description: A Helm chart for InfluxDB v2
home: InfluxDB | InfluxData
type: application
version: 2.1.1
Thank you
Best regatds