Install InfluxDb client npm module:
npm install --save @influxdata/influxdb-client
To create an alert in InfluxDb, navigate to Alerts in the side menu and click on Threshold Check button.
In the next step we need to define a query for the alert check. In this case we are creating a query to retrieve temperature data from senseHat01 sensor.
Notice the Window period on the right hand side of the screen - it can be set in the Confugure check tab, but for now it displays the default period of the time window that the data will be aggregated by.
Then we select the aggregate function to be used on the query result.
Going to the Configure check tab now, we can specify the frequency that the check should be ran at (our aggregating time window).
Then on the right hand side we can specify tresholds for alerts of different types, such as OK, WARN or CRITICAL for example.
After inputting all the values, click the tick button in the upper right corner and the alert is all set up at this stage.
Now going to the Alerts History menu, we can see any alerts that were triggered, their time, type and messages attached.
Slack notifications were set up following this guide:
https://www.influxdata.com/blog/tldr-influxdb-tech-tips-configuring-slack-notification-with-influxdb/
Go to https://api.slack.com/apps and sign in to your Slack account. Select an existing workspace or create a new one specifically for the IoT notifications.
Click the Create an App button.
Select Create from scratch
Type in the name of your app and select the workspace to be used for IoT notifications.
Activate incoming webhooks by toggling the switch On.
Click Add new webhook to workspace
Select a Slack channel which will be used by the app to post notifications and click Allow.
Your webhook has now been created. Copy the Webhook URL and go to InfluxDb.
Free 5 day forecast data available: https://openweathermap.org/forecast5