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:
parent
9d4f51e970
commit
f45cf7900e
1 changed files with 3 additions and 0 deletions
|
@ -42,6 +42,7 @@ module.exports.CreateMonitoring = function (parent, args) {
|
||||||
RelaySessions: { description: "Relay Sessions" }, // parent.webserver.relaySessionCount
|
RelaySessions: { description: "Relay Sessions" }, // parent.webserver.relaySessionCount
|
||||||
RelayCount: { description: "Relay Count" } // Object.keys(parent.webserver.wsrelays).length30bb4fb74dfb758d36be52a7
|
RelayCount: { description: "Relay Count" } // Object.keys(parent.webserver.wsrelays).length30bb4fb74dfb758d36be52a7
|
||||||
}
|
}
|
||||||
|
obj.collectors = [];
|
||||||
if (parent.config.settings.prometheus != null) { // Create Prometheus Monitoring Endpoint
|
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))) {
|
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');
|
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
|
blockedAgents: parent.webserver.blockedAgents
|
||||||
};
|
};
|
||||||
for (const key in counters) { obj.counterMetrics[key].prometheus.reset(); obj.counterMetrics[key].prometheus.inc(counters[key]); }
|
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.set('Content-Type', obj.prometheus.register.contentType);
|
||||||
res.end(await obj.prometheus.register.metrics());
|
res.end(await obj.prometheus.register.metrics());
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -111,4 +113,5 @@ module.exports.CreateMonitoring = function (parent, args) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue