-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
24 lines (20 loc) · 896 Bytes
/
index.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
const express = require("express");
const promclient = require("prom-client");
const { Monitor } = require("@labbsr0x/express-monitor");
const app = express();
Monitor.init(app, true);
// a generic endpoint to simulate a valid operation
app.all(/^(?!\/metrics$).*/, (req, res) => {
setTimeout(() => {
res.status(200).header("Content-Type", "text/plain").send(JSON.stringify({"success":true}));
}, 4000);
})
// A RegisterDepedencyMetricsCallback will be automatically injected into the HealthCheckCallback
Monitor.watchDependencies((register) => {
// here you implement the logic to go after your dependencies and check their health
// the return must be an array of HealthCheckResult{name, status}
register({ name: "Fake dependency 1", up: true});
register({ name: "Fake dependency 2", up: false});
});
// runs the express app on port 23498
app.listen(23498)