-
Notifications
You must be signed in to change notification settings - Fork 1
/
createAlarm.js
30 lines (27 loc) · 922 Bytes
/
createAlarm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const request = require("request");
// Cumulocity credentials
const credentials = $config.params.username + ":" + $config.params.password;
// Basic authorization and alarm details
const options = {
"url" : $config.params.server + "/alarm/alarms",
"headers" : {
"Authorization" : "Basic " + Buffer.from(credentials).toString("base64"),
"Accept" : "application/json"
},
"json" : {
"source": {
"id": $config.params.trackerId
},
"type": "c8y_Application__Microservice_unhealthy",
"text": "The microservice " + $config.params.microservice + " is not UP and running",
"severity": "MINOR",
"status": "ACTIVE",
"time": new Date(Date.now()).toISOString()
}
};
// Create the alarm
request.post(options, function (error, response, body) {
if (body.id !== undefined) {
$export(null, { "alarmId" : body.id });
}
});