@certik/skynet 0.8.12 → 0.8.15
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 +13 -1
- package/app.js +8 -16
- package/log.js +13 -5
- package/monitor.js +8 -65
- package/opsgenie.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.15
|
|
4
|
+
|
|
5
|
+
- OpsGenie bug fix
|
|
6
|
+
|
|
7
|
+
## 0.8.14
|
|
8
|
+
|
|
9
|
+
- Switched monitor to send to opsgenie only
|
|
10
|
+
|
|
11
|
+
## 0.8.13
|
|
12
|
+
|
|
13
|
+
- Added `inline.error` function to `log` library
|
|
14
|
+
|
|
3
15
|
## 0.8.12
|
|
4
16
|
|
|
5
|
-
- Added `log` library
|
|
17
|
+
- Added `log` library to print one line log
|
|
6
18
|
|
|
7
19
|
## 0.8.11
|
|
8
20
|
|
package/app.js
CHANGED
|
@@ -202,8 +202,7 @@ function indexer({ name, selector, build, check, env = {}, region = "us-east-1"
|
|
|
202
202
|
bin: `${bin} check`,
|
|
203
203
|
schedule: check.schedule,
|
|
204
204
|
cpu: check.cpu || 100,
|
|
205
|
-
mem: check.mem || 100
|
|
206
|
-
hasSlack: check.slackChannel,
|
|
205
|
+
mem: check.mem || 100
|
|
207
206
|
},
|
|
208
207
|
});
|
|
209
208
|
|
|
@@ -216,8 +215,7 @@ function indexer({ name, selector, build, check, env = {}, region = "us-east-1"
|
|
|
216
215
|
type: "stateless",
|
|
217
216
|
selector,
|
|
218
217
|
check: check.func,
|
|
219
|
-
maxRetry: check.maxRetry
|
|
220
|
-
slackChannel: check.slackChannel,
|
|
218
|
+
maxRetry: check.maxRetry
|
|
221
219
|
});
|
|
222
220
|
|
|
223
221
|
monitor();
|
|
@@ -317,8 +315,7 @@ function modeIndexer({ name, selector, state, build, validate, check, env = {},
|
|
|
317
315
|
bin: `${bin} check`,
|
|
318
316
|
schedule: check.schedule,
|
|
319
317
|
cpu: check.cpu || 100,
|
|
320
|
-
mem: check.mem || 100
|
|
321
|
-
hasSlack: check.slackChannel,
|
|
318
|
+
mem: check.mem || 100
|
|
322
319
|
},
|
|
323
320
|
});
|
|
324
321
|
|
|
@@ -332,8 +329,7 @@ function modeIndexer({ name, selector, state, build, validate, check, env = {},
|
|
|
332
329
|
selector,
|
|
333
330
|
mode: true,
|
|
334
331
|
check: check.func,
|
|
335
|
-
maxRetry: check.maxRetry
|
|
336
|
-
slackChannel: check.slackChannel,
|
|
332
|
+
maxRetry: check.maxRetry
|
|
337
333
|
});
|
|
338
334
|
|
|
339
335
|
monitor();
|
|
@@ -421,8 +417,7 @@ function producer({ name, selector, produce, check, state, env = {}, region = "u
|
|
|
421
417
|
bin: `${bin} check`,
|
|
422
418
|
schedule: check.schedule,
|
|
423
419
|
cpu: check.cpu || 100,
|
|
424
|
-
mem: check.mem || 100
|
|
425
|
-
hasSlack: check.slackChannel,
|
|
420
|
+
mem: check.mem || 100
|
|
426
421
|
},
|
|
427
422
|
});
|
|
428
423
|
|
|
@@ -435,8 +430,7 @@ function producer({ name, selector, produce, check, state, env = {}, region = "u
|
|
|
435
430
|
type: "stateful",
|
|
436
431
|
selector,
|
|
437
432
|
check: check.func,
|
|
438
|
-
maxRetry: check.maxRetry
|
|
439
|
-
slackChannel: check.slackChannel,
|
|
433
|
+
maxRetry: check.maxRetry
|
|
440
434
|
});
|
|
441
435
|
|
|
442
436
|
monitor();
|
|
@@ -515,8 +509,7 @@ function consumer({ name, selector, consume, check, env = {}, region = "us-east-
|
|
|
515
509
|
bin: `${bin} check`,
|
|
516
510
|
schedule: check.schedule,
|
|
517
511
|
cpu: check.cpu || 100,
|
|
518
|
-
mem: check.mem || 100
|
|
519
|
-
hasSlack: check.slackChannel,
|
|
512
|
+
mem: check.mem || 100
|
|
520
513
|
},
|
|
521
514
|
});
|
|
522
515
|
|
|
@@ -529,8 +522,7 @@ function consumer({ name, selector, consume, check, env = {}, region = "us-east-
|
|
|
529
522
|
type: "stateless",
|
|
530
523
|
selector,
|
|
531
524
|
check: check.func,
|
|
532
|
-
maxRetry: check.maxRetry
|
|
533
|
-
slackChannel: check.slackChannel,
|
|
525
|
+
maxRetry: check.maxRetry
|
|
534
526
|
});
|
|
535
527
|
|
|
536
528
|
monitor();
|
package/log.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
inline.log = function (...args) {
|
|
1
|
+
function getLine(params) {
|
|
3
2
|
let line = `${new Date().toISOString()}\t`;
|
|
4
3
|
|
|
5
4
|
// Convert to string and filter out newline to tabs (AWS Athena)
|
|
6
|
-
for (let i = 0, l =
|
|
5
|
+
for (let i = 0, l = params.length; i < l; i++) {
|
|
7
6
|
// Certain objects don't get converted
|
|
8
7
|
// Note using JSON.stringfy may be too slow for large objects
|
|
9
|
-
line += `${
|
|
8
|
+
line += `${params[i]} `.replace(/\n/gm, "\t");
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
return line.trim();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const inline = {
|
|
15
|
+
log: function (...args) {
|
|
16
|
+
console.log(getLine(args));
|
|
17
|
+
},
|
|
18
|
+
error: function (...args) {
|
|
19
|
+
console.error(getLine(args));
|
|
20
|
+
},
|
|
13
21
|
};
|
|
14
22
|
|
|
15
23
|
module.exports = {
|
package/monitor.js
CHANGED
|
@@ -4,9 +4,8 @@ const { getSelectorFlags, getSelectorDesc, toSelectorString } = require("./selec
|
|
|
4
4
|
const { getBinaryName } = require("./cli");
|
|
5
5
|
const { exponentialRetry } = require("./availability");
|
|
6
6
|
const { getIndexerLatestId, getIndexerValidatedId, getIndexerState } = require("./indexer");
|
|
7
|
-
const { postMessage } = require("./slack");
|
|
8
7
|
const { postGenieMessage } = require("./opsgenie");
|
|
9
|
-
const { getJobName
|
|
8
|
+
const { getJobName } = require("./deploy");
|
|
10
9
|
|
|
11
10
|
const ERROR_LEVEL = {
|
|
12
11
|
INFO: "Info",
|
|
@@ -90,7 +89,6 @@ function createMonitor({
|
|
|
90
89
|
name,
|
|
91
90
|
type = "stateless",
|
|
92
91
|
mode = false,
|
|
93
|
-
slackChannel,
|
|
94
92
|
selector = {},
|
|
95
93
|
check,
|
|
96
94
|
maxRetry = 2,
|
|
@@ -178,69 +176,14 @@ ${
|
|
|
178
176
|
if (result.length > 0) {
|
|
179
177
|
console.log("Found Errors", result);
|
|
180
178
|
|
|
181
|
-
if (
|
|
182
|
-
// TODO: deduplicate
|
|
183
|
-
await postMessage(
|
|
184
|
-
slackChannel,
|
|
185
|
-
{
|
|
186
|
-
text: `${jobName} Monitor Errors: ${result.map((m) => m.message || m).join("\n")}`,
|
|
187
|
-
blocks: [
|
|
188
|
-
{
|
|
189
|
-
type: "header",
|
|
190
|
-
text: {
|
|
191
|
-
type: "plain_text",
|
|
192
|
-
text: `${jobName} Monitor Errors`,
|
|
193
|
-
emoji: true,
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
type: "divider",
|
|
198
|
-
},
|
|
199
|
-
...sortErrors(result)
|
|
200
|
-
.map((m) => {
|
|
201
|
-
return [
|
|
202
|
-
{
|
|
203
|
-
type: "context",
|
|
204
|
-
elements: [
|
|
205
|
-
{
|
|
206
|
-
type: "plain_text",
|
|
207
|
-
text: `${LEVEL_EMOJI[m.type || ERROR_LEVEL.CRITICAL]} ${m.type || ERROR_LEVEL.CRITICAL}`,
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
type: "section",
|
|
213
|
-
text: {
|
|
214
|
-
type: "mrkdwn",
|
|
215
|
-
text: m.message || m,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
];
|
|
219
|
-
})
|
|
220
|
-
.flat(),
|
|
221
|
-
{
|
|
222
|
-
type: "actions",
|
|
223
|
-
elements: [
|
|
224
|
-
{
|
|
225
|
-
type: "button",
|
|
226
|
-
text: {
|
|
227
|
-
type: "plain_text",
|
|
228
|
-
text: "View Details",
|
|
229
|
-
},
|
|
230
|
-
value: "view_details",
|
|
231
|
-
url: `${await getNomadAddr(production)}/ui/jobs/${jobName}`,
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
},
|
|
237
|
-
verbose
|
|
238
|
-
);
|
|
239
|
-
|
|
179
|
+
if (production) {
|
|
240
180
|
// Also alert on opsgenie (func prevents duplicate alerts)
|
|
241
181
|
await postGenieMessage(
|
|
242
|
-
`${jobName} Monitor Errors
|
|
243
|
-
|
|
182
|
+
`${jobName} Monitor Errors`,
|
|
183
|
+
`${sortErrors(result)
|
|
184
|
+
.map((m) => m.message || m)
|
|
185
|
+
.join("\n")}`,
|
|
186
|
+
verbose
|
|
244
187
|
);
|
|
245
188
|
}
|
|
246
189
|
|
|
@@ -270,4 +213,4 @@ ${
|
|
|
270
213
|
return { monitor };
|
|
271
214
|
}
|
|
272
215
|
|
|
273
|
-
module.exports = { createMonitor, ERROR_LEVEL };
|
|
216
|
+
module.exports = { createMonitor, ERROR_LEVEL, LEVEL_EMOJI };
|
package/opsgenie.js
CHANGED