1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Add collectors to monitoring

This commit is contained in:
Daniel Hammerschmidt 2025-02-12 17:39:15 +01:00 committed by GitHub
parent 9d4f51e970
commit f45cf7900e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,6 +42,7 @@ module.exports.CreateMonitoring = function (parent, args) {
RelaySessions: { description: "Relay Sessions" }, // parent.webserver.relaySessionCount
RelayCount: { description: "Relay Count" } // Object.keys(parent.webserver.wsrelays).length30bb4fb74dfb758d36be52a7
}
obj.collectors = [];
if (parent.config.settings.prometheus != null) { // Create Prometheus Monitoring Endpoint
if ((typeof parent.config.settings.prometheus == 'number') && ((parent.config.settings.prometheus < 1) || (parent.config.settings.prometheus > 65535))) {
console.log('Promethus port number is invalid, Prometheus metrics endpoint has be disabled');
@ -102,6 +103,7 @@ module.exports.CreateMonitoring = function (parent, args) {
blockedAgents: parent.webserver.blockedAgents
};
for (const key in counters) { obj.counterMetrics[key].prometheus.reset(); obj.counterMetrics[key].prometheus.inc(counters[key]); }
await Promise.all(obj.collectors.map((collector) => (collector())));
res.set('Content-Type', obj.prometheus.register.contentType);
res.end(await obj.prometheus.register.metrics());
} catch (ex) {
@ -111,4 +113,5 @@ module.exports.CreateMonitoring = function (parent, args) {
});
}
}
return obj;
}