koishi-plugin-exporter
Version:
Koishi OpenMetrics Exporter
24 lines (23 loc) • 778 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.channels = void 0;
const koishi_1 = require("koishi");
const prom_client_1 = require("prom-client");
const common_1 = require("../common");
const channels = (ctx, config, register) => {
new prom_client_1.Gauge({
name: common_1.prefix + common_1.metricNames.channels,
help: 'Total channels.',
registers: [register],
labelNames: ['instance_name'],
async collect() {
const channels = await ctx.database
.select('channel')
.execute((x) => koishi_1.$.length(x.id));
this.set({
instance_name: config.name,
}, channels);
},
});
};
exports.channels = channels;