Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manasesjesus/c8y_microservice-nodejs
Cumulocity IoT - Microservice developed using Node.js and Docker. It notifies a Slack channel when there are alarms in the subscribed tenants.
https://github.com/manasesjesus/c8y_microservice-nodejs
cumulocity-iot iot-platform microservices monitoring slack
Last synced: 3 days ago
JSON representation
Cumulocity IoT - Microservice developed using Node.js and Docker. It notifies a Slack channel when there are alarms in the subscribed tenants.
- Host: GitHub
- URL: https://github.com/manasesjesus/c8y_microservice-nodejs
- Owner: manasesjesus
- License: mit
- Created: 2019-05-07T07:47:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T22:42:56.000Z (almost 2 years ago)
- Last Synced: 2024-11-21T23:37:02.597Z (2 months ago)
- Topics: cumulocity-iot, iot-platform, microservices, monitoring, slack
- Language: JavaScript
- Homepage:
- Size: 495 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Cumulocity IoT Microservice
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/49064d3b224c4c9284cf965d3e45e619)](https://app.codacy.com/app/manasesjesus/c8y_microservice_nodejs?utm_source=github.com&utm_medium=referral&utm_content=manasesjesus/c8y_microservice_nodejs&utm_campaign=Badge_Grade_Dashboard)
Cumulocity IoT microservice developed using Node.js and Docker. It notifies a Slack channel when there are alarms in the subscribed tenants.
### Prerequisites
* Local Docker installation.
* A [Cumulocity IoT](https://cumulocity.com) account. Create a free trial to test this example.
* Slack channel to post messages to, [Slack app and OAuth token](https://slack.dev/node-slack-sdk/getting-started).
* A *.env* file in the root directory with the following content:```properties
PORT=80
SLACK_OAUTH_TOKEN=
SLACK_CHANNEL_ID=
```### Build
Execute the following commands to build the Docker image and save it as *image.tar*:
```shell
$ 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.
```shell
$ 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.
### Deployment
Deploy the microservice application (refer to [Adding own applications](https://cumulocity.com/guides/users-guide/administration/#a-name-adding-applications-a-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.
### Execution
Use a web browser or a terminal command (e.g. cURL) to make a GET request to the microservice endpoints.
```http
GET .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.
![Slack app posting alarms](microservice-slack-alarms.png)