diff --git a/erizo_controller/ROV/rovMetricsGatherer.js b/erizo_controller/ROV/rovMetricsGatherer.js index c4a8f39c00..20ba4a51db 100644 --- a/erizo_controller/ROV/rovMetricsGatherer.js +++ b/erizo_controller/ROV/rovMetricsGatherer.js @@ -1,16 +1,21 @@ class RovMetricsGatherer { - constructor(rovClient, promClient, logger) { + constructor(rovClient, promClient, statsPrefix, logger) { this.rovClient = rovClient; + this.prefix = statsPrefix; this.prometheusMetrics = { - activeRooms: new promClient.Gauge({ name: 'active_rooms', help: 'active rooms in all erizoControllers' }), - activeClients: new promClient.Gauge({ name: 'active_clients', help: 'active clients in all erizoControllers' }), - totalPublishers: new promClient.Gauge({ name: 'total_publishers', help: 'total active publishers' }), - totalSubscribers: new promClient.Gauge({ name: 'total_subscribers', help: 'total active subscribers' }), - activeErizoJsProcesses: new promClient.Gauge({ name: 'active_erizojs_processes', help: 'active processes' }), + activeRooms: new promClient.Gauge({ name: this.getNameWithPrefix('active_rooms'), help: 'active rooms in all erizoControllers' }), + activeClients: new promClient.Gauge({ name: this.getNameWithPrefix('active_clients'), help: 'active clients in all erizoControllers' }), + totalPublishers: new promClient.Gauge({ name: this.getNameWithPrefix('total_publishers'), help: 'total active publishers' }), + totalSubscribers: new promClient.Gauge({ name: this.getNameWithPrefix('total_subscribers'), help: 'total active subscribers' }), + activeErizoJsProcesses: new promClient.Gauge({ name: this.getNameWithPrefix('active_erizojs_processes'), help: 'active processes' }), }; this.log = logger; } + getNameWithPrefix(name) { + return `${this.prefix}${name}`; + } + getTotalRooms() { this.log.debug('Getting total rooms'); return this.rovClient.runInComponentList('console.log(context.rooms.size)', this.rovClient.components.erizoControllers) diff --git a/erizo_controller/ROV/rovMetricsServer.js b/erizo_controller/ROV/rovMetricsServer.js index ef9b34e5c3..32cc77328a 100644 --- a/erizo_controller/ROV/rovMetricsServer.js +++ b/erizo_controller/ROV/rovMetricsServer.js @@ -65,12 +65,14 @@ log.info('Starting: Connecting to rabbitmq'); amqper.connect(() => { log.info('connected to rabbitmq'); const rovClient = new RovClient(amqper); - const rovMetricsGatherer = new RovMetricsGatherer(rovClient, promClient, log); + const rovMetricsGatherer = + new RovMetricsGatherer(rovClient, promClient, config.rov.statsPrefix, log); + promClient.collectDefaultMetrics( + { prefix: config.rov.statsPrefix, timeout: config.rov.statsPeriod }); setInterval(() => { rovMetricsGatherer.gatherMetrics().then(() => { - log.debug('Gathered metrics, promClient Collecting'); - promClient.collectDefaultMetrics(); + log.debug('Gathered licode metrics'); }) .catch((error) => { log.error('Error gathering metrics', error); diff --git a/scripts/licode_default.js b/scripts/licode_default.js index a5c84febc1..b25f7ddf4f 100644 --- a/scripts/licode_default.js +++ b/scripts/licode_default.js @@ -189,7 +189,8 @@ config.rov = {}; config.rov.statsPeriod = 20000; // The port to expose the stats to prometheus config.rov.serverPort = 3005; - +// A prefix for the prometheus stats +config.rov.statsPrefix = "licode_"; /***** END *****/ // Following lines are always needed. var module = module || {};