-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (37 loc) · 983 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { Gauge } = require("prom-client");
let prometheusMetricsExporter;
/**
* ! Use this function if you want to export the logs without any kind of alert
*/
const Warning = (message) => {
return prometheusMetricsExporter.inc({ level: "warning", message }, 1);
};
/**
* ! Use this function if you want to export the logs and warn of a possible error
*/
const Alert = (message) => {
return prometheusMetricsExporter.inc({ level: "alert", message }, 1);
};
/**
* Start prometheus metrics exporter
*/
const InitElvenAlertManager = () => {
if (prometheusMetricsExporter) {
return {
prometheusMetricsExporter,
Alert,
Warning,
};
}
prometheusMetricsExporter = new Gauge({
name: "logger_logs_bucket",
help: "Returns logger level and message in metrics",
labelNames: ["level", "message"],
});
return {
prometheusMetricsExporter,
Alert,
Warning,
};
};
module.exports = { InitElvenAlertManager, Alert, Warning };