mirror of
https://github.com/janderedev/automod.git
synced 2024-12-22 10:45:27 +00:00
add bridged_channels metric
This commit is contained in:
parent
e0bc136a37
commit
50de258a9f
|
@ -1,6 +1,6 @@
|
||||||
import prom from 'prom-client';
|
import prom from 'prom-client';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import { logger } from '.';
|
import { BRIDGE_CONFIG, logger } from '.';
|
||||||
|
|
||||||
const PORT = Number(process.env.BRIDGE_METRICS_PORT);
|
const PORT = Number(process.env.BRIDGE_METRICS_PORT);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ prom.collectDefaultMetrics({ prefix: 'automod_bridge_' });
|
||||||
|
|
||||||
const metrics = {
|
const metrics = {
|
||||||
messages: new prom.Counter({ name: 'messages', help: 'Bridged message events', labelNames: [ 'source', 'type' ] }),
|
messages: new prom.Counter({ name: 'messages', help: 'Bridged message events', labelNames: [ 'source', 'type' ] }),
|
||||||
|
bridged_channels: new prom.Gauge({ name: 'bridged_channels', help: 'How many channels are bridged' }),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNaN(PORT)) {
|
if (!isNaN(PORT)) {
|
||||||
|
@ -27,6 +28,13 @@ if (!isNaN(PORT)) {
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(PORT, () => logger.done(`Prometheus metrics ready`));
|
server.listen(PORT, () => logger.done(`Prometheus metrics ready`));
|
||||||
|
|
||||||
|
async function updateMetrics() {
|
||||||
|
metrics.bridged_channels.set(await BRIDGE_CONFIG.count({ }));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMetrics();
|
||||||
|
setInterval(updateMetrics, 1000 * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { metrics }
|
export { metrics }
|
||||||
|
|
Loading…
Reference in a new issue