# InfluxDB alerts and notifications

**URL:** <https://community.influxdata.com/t/influxdb-alerts-and-notifications/30014>\
**Category:** Checks & Notifications\
**Tags:** influxdb\
**Created:** [May 19, 2023, 9:23pm UTC](https://community.influxdata.com/t/influxdb-alerts-and-notifications/30014 "2023-05-19T21:23:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcf](https://avatars.discourse-cdn.com/v4/letter/l/85f322/32.png) [@lcf](https://community.influxdata.com/u/lcf)\
**Post date:** [May 19, 2023, 9:23pm UTC](https://community.influxdata.com/t/influxdb-alerts-and-notifications/30014/1 "2023-05-19T21:23:10Z")

</div>

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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](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 :

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/f/fbe0549dfba4473a6f29b211c2e251908bb89e70.png)

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

Thanks for your help,  
LCF
