@certik/skynet 0.10.4 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/deploy.js +4 -1
- package/monitor.js +8 -6
- package/opsgenie.js +10 -15
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.5
|
|
4
|
+
|
|
5
|
+
- BREAKING Changed the signature of `postGenieMessage` function in `opsgenie` to make it more customizable
|
|
6
|
+
|
|
3
7
|
## 0.10.4
|
|
4
8
|
|
|
5
|
-
- Fixed
|
|
9
|
+
- Fixed typo in coinmarketcap ids in `PROTOCOLS` in `const`
|
|
6
10
|
|
|
7
11
|
## 0.10.3
|
|
8
12
|
|
package/deploy.js
CHANGED
|
@@ -91,7 +91,8 @@ const genConfig = ({
|
|
|
91
91
|
port "http" {
|
|
92
92
|
static = ${service.port}
|
|
93
93
|
}
|
|
94
|
-
}`
|
|
94
|
+
}`
|
|
95
|
+
: ""
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
task "log-shipper" {
|
|
@@ -437,6 +438,7 @@ function createModeDeploy({
|
|
|
437
438
|
SKYNET_NOMAD_PRODUCTION_ADDR: null,
|
|
438
439
|
SKYNET_SLACK_TOKEN: null,
|
|
439
440
|
OPSGENIE_API_KEY: null,
|
|
441
|
+
OPSGENIE_END_POINT: null,
|
|
440
442
|
},
|
|
441
443
|
region,
|
|
442
444
|
cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
|
|
@@ -596,6 +598,7 @@ function createDeploy({
|
|
|
596
598
|
SKYNET_NOMAD_PRODUCTION_ADDR: null,
|
|
597
599
|
SKYNET_SLACK_TOKEN: null,
|
|
598
600
|
OPSGENIE_API_KEY: null,
|
|
601
|
+
OPSGENIE_END_POINT: null,
|
|
599
602
|
},
|
|
600
603
|
region,
|
|
601
604
|
cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
|
package/monitor.js
CHANGED
|
@@ -153,12 +153,14 @@ ${
|
|
|
153
153
|
|
|
154
154
|
// alert on opsgenie
|
|
155
155
|
await postGenieMessage(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
{
|
|
157
|
+
message: `Failed Service Check: ${jobName}`,
|
|
158
|
+
description: `<p><b>Service:</b><a href="${nomadAddr}/ui/jobs/${jobName}" target="_blank">${jobName}</a></p><p><b>Issues</b></p><ul>${sortErrors(
|
|
159
|
+
result
|
|
160
|
+
)
|
|
161
|
+
.map((m) => `<li><b>${m.type}:</b> ${m.message}</li>`)
|
|
162
|
+
.join("")}</ul>`,
|
|
163
|
+
},
|
|
162
164
|
verbose
|
|
163
165
|
);
|
|
164
166
|
} else {
|
package/opsgenie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const fetch = require("node-fetch");
|
|
2
|
-
const
|
|
2
|
+
const md5 = require("md5");
|
|
3
3
|
|
|
4
4
|
function getGenieKey() {
|
|
5
5
|
return process.env.OPSGENIE_API_KEY;
|
|
@@ -15,32 +15,28 @@ function getGenieEndPoint() {
|
|
|
15
15
|
return process.env.OPSGENIE_END_POINT;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function postGenieMessage(
|
|
18
|
+
async function postGenieMessage(body, verbose) {
|
|
19
19
|
try {
|
|
20
20
|
const genieKey = getGenieKey();
|
|
21
21
|
const genieEndPoint = getGenieEndPoint();
|
|
22
22
|
|
|
23
|
-
const body = {
|
|
24
|
-
message: msg,
|
|
25
|
-
description: desc
|
|
26
|
-
};
|
|
27
|
-
|
|
28
23
|
// Prevents duplicate alerts (See Opsgenie doc about alias)
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
if (!body.alias) {
|
|
25
|
+
body.alias = md5(body.message);
|
|
26
|
+
}
|
|
31
27
|
|
|
32
28
|
if (verbose) {
|
|
33
|
-
console.log(`Making API call to Opsgenie
|
|
29
|
+
console.log(`Making API call to Opsgenie`, JSON.stringify(body, null, 2));
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
// Makes the call using fetch and ENV variables
|
|
37
33
|
const response = await fetch(genieEndPoint, {
|
|
38
34
|
method: "POST",
|
|
39
35
|
headers: {
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
"Content-Type": "application/json",
|
|
37
|
+
Authorization: `GenieKey ${genieKey}`,
|
|
42
38
|
},
|
|
43
|
-
body: JSON.stringify(body)
|
|
39
|
+
body: JSON.stringify(body),
|
|
44
40
|
});
|
|
45
41
|
|
|
46
42
|
const result = await response.json();
|
|
@@ -48,8 +44,7 @@ async function postGenieMessage(msg, desc, verbose) {
|
|
|
48
44
|
console.log(`Result of API call to Opsgenie... ${result}`);
|
|
49
45
|
}
|
|
50
46
|
|
|
51
|
-
return result
|
|
52
|
-
|
|
47
|
+
return result;
|
|
53
48
|
} catch (error) {
|
|
54
49
|
console.error("Failed to make opsgenie API call", error);
|
|
55
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certik/skynet",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "Skynet Shared JS library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "CertiK Engineering",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"execa": "^5.0.0",
|
|
19
19
|
"express": "^4.18.1",
|
|
20
20
|
"kafkajs": "^1.15.0",
|
|
21
|
+
"md5": "^2.3.0",
|
|
21
22
|
"meow": "^7.0.1",
|
|
22
23
|
"node-fetch": "^2.6.1",
|
|
23
|
-
"object-hash": "^2.2.0",
|
|
24
24
|
"snowflake-sdk": "^1.6.3",
|
|
25
25
|
"web3": "^1.3.5",
|
|
26
26
|
"which": "^2.0.2"
|