InfluxDB alerts and notifications

Hi Influx Forum!

I have been trying to make alerts and notifications work for a few days but I can’t get a reliable result.

To sort thing out, I created a new Data for testing.
I feed it through inline commands.
I created a check, notification endpoint and a notification rule.
But I can’t get any alerts.

here is my check :

import “influxdata/influxdb/monitor”
import “influxdata/influxdb/v1”

data =
from(bucket: “TestBucket”)
|> range(start: -1m)
|> filter(fn: (r) => r[“_measurement”] == “testMeasurement”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 1m, fn: last, createEmpty: false)

option task = {name: “TestSite - TestMeasurement”, every: 1m, offset: 5s}

check = {
_check_id: “0b39182323142000”,
_check_name: “TestSite - TestMeasurement”,
_type: “threshold”,
tags: {Site: “TestSite”},
}
ok = (r) => r[“value”] < 1.5
info = (r) => r[“value”] > 1.5
warn = (r) => r[“value”] > 2.5
crit = (r) => r[“value”] > 3.5
messageFn = (r) => “Check: ${ r._check_name } is: ${ r._level }”

data
|> v1"fieldsAsCols"
|> monitor[“check”](
data: check,
messageFn: messageFn,
ok: ok,
info: info,
warn: warn,
crit: crit,
)

here is my notification rule :

import “influxdata/influxdb/monitor”
import “slack”
import “influxdata/influxdb/secrets”
import “experimental”

option task = {name: “TestSite - Crit”, every: 1m, offset: 15s}

slack_endpoint =
slack[“endpoint”](
url: “https://hooks.slack.com/services/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”,
)
notification = {
_notification_rule_id: “0b39188537c60000”,
_notification_rule_name: “TestSite - Crit”,
_notification_endpoint_id: “0b0c01c532585000”,
_notification_endpoint_name: “Ohana_public Slack Channel”,
}
statuses = monitor[“from”](start: -2m, fn: (r) => r[“Site”] == “TestSite”)
any_to_crit = statuses |> monitor[“stateChanges”](fromLevel: “any”, toLevel: “crit”)
all_statuses =
any_to_crit |> filter(fn: (r) => r[“_time”] >= experimental[“subDuration”](from: now(), d: 1m))

all_statuses
|> monitor[“notify”](
data: notification,
endpoint:
slack_endpoint(
mapFn:
(r) =>
({
channel: “”,
text:
“Notification Rule: ${ r._notification_rule_name }
check: ${ r._check_name }
message: ${ r._message }”,
color:
if r[“_level”] == “crit” then
“danger”
else if r[“_level”] == “warn” then
“warning”
else
“good”,
}),
),
)

I known the slack webhook is working.
the check produces statuses as it is supposed to :

Why don’t I receive alerts?
What did I do wrong?
Is the alerting system stable and reliable?

Thanks for your help,
LCF