Get a Slack message when a limit is crossed
Post to a Slack channel when a reading crosses a value. The test keeps running.
Before you start
- A Slack connector on Connectors in the console. Its bot needs the
chat:writescope. See Slack. - The bot invited to the channel it posts in.
- A Trellis setup you can deploy from Phloem Computer. See Trellis.
Steps
In the console, open Alerts and choose New role.
Type a role name, such as
test-conductor. Use lowercase letters, digits,-or_.Pick your Slack connector in choose a connector… and type the channel, such as
#test-alerts. To post in more places, press + another channel.Press Save.
In Computer, open Trellis and open your setup in Code. Add an
alarmthat names the role innotify=:setup("heater") ch = channels() ch.read("/demo/temperature", unit="degC") alarm( "too_hot", when=ch["/demo/temperature"].above(80), severity="warn", notify=["test-conductor"], ) page("Heater test", layout=col(alarms()))whenabove(x),below(x),within(lo, hi)oroutside(lo, hi)on a channelseverityinfo,warnorcriticalnotifyrole names from Alerts Press Deploy.
Check it worked
When the alarm fires, Slack gets a message such as
[warn] too_hot on /demo/temperature …, with how long ago it fired.
On Alerts, Recent deliveries lists each firing and its outcome:
| Outcome | Means |
|---|---|
| delivered | posted to the channel |
| rolled up | counted together with repeats or a burst from the same device |
| too old to page | fired too long ago to post as live |
| no such role | notify= names a role Alerts does not have |
| no working channel | the role's connector is gone or inactive |
| failed · retrying | the send failed and is retried; hover for the reason |
Messages are sent from the cloud. A firing reaches Slack once the device's data does, so an offline device posts late, with the firing's age.
Updated