Cumulocity IoT microservice developed using Node.js and Docker. It notifies a Slack channel when there are alarms in the subscribed tenants.
- Local Docker installation.
- A Cumulocity IoT account. Create a free trial to test this example.
- Slack channel to post messages to, Slack app and OAuth token.
- A .env file in the root directory with the following content:
PORT=80
SLACK_OAUTH_TOKEN=<YOUR-TOKEN-GOES-HERE>
SLACK_CHANNEL_ID=<YOUR-CHANNEL_ID-GOES-HERE>
Execute the following commands to build the Docker image and save it as image.tar:
$ docker build -t mynode-microservice .
$ docker save mynode-microservice > "image.tar"
Then pack image.tar together with the manifest cumulocity.json into a ZIP file.
$ zip mynode-microservice cumulocity.json image.tar
The resulting mynode-microservice.zip file contains the microservice and it is ready to be uploaded to the Cumulocity IoT platform.
Deploy the microservice application (refer to Adding own applications in the Cumulocity IoT's User guide) and subscribe it afterwards. It may take some minutes for the ZIP file to be uploaded.
Use a web browser or a terminal command (e.g. cURL) to make a GET request to the microservice endpoints.
GET <tenant-domain>.cumulocity.com/service/mynode-microservice/environment
The Slack channel will get the posted messages every time a new alarm is raised on the subscribed tenants.
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.