From f7de45c797a2cacbaf2b0b36411da13d9e5130a1 Mon Sep 17 00:00:00 2001 From: Masanori Fujita Date: Thu, 19 Nov 2020 14:54:55 +0100 Subject: [PATCH] Fixed Bug #5 --- prometheus-exporter/prometheus-adapter.js | 4 ++-- prometheus-exporter/prometheus-metric-config.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/prometheus-exporter/prometheus-adapter.js b/prometheus-exporter/prometheus-adapter.js index 9772562..cee1e9b 100644 --- a/prometheus-exporter/prometheus-adapter.js +++ b/prometheus-exporter/prometheus-adapter.js @@ -34,14 +34,14 @@ module.exports = { } }, addCounter: function (metricConfig) { + metricConfig.registers = [customRegistry]; const metric = new client.Counter(metricConfig); - customRegistry.registerMetric(metric); red.log.info('Added Prometheus Counter ' + metricConfig.name + ' ' + JSON.stringify(metricConfig, null, 2)); return metric; }, addGauge: function (metricConfig) { + metricConfig.registers = [customRegistry]; const metric = new client.Gauge(metricConfig); - customRegistry.registerMetric(metric); red.log.info('Added Prometheus Gauge ' + metricConfig.name+ ' ' + JSON.stringify(metricConfig, null, 2)); return metric; }, diff --git a/prometheus-exporter/prometheus-metric-config.js b/prometheus-exporter/prometheus-metric-config.js index dc6ea43..c94afdb 100644 --- a/prometheus-exporter/prometheus-metric-config.js +++ b/prometheus-exporter/prometheus-metric-config.js @@ -7,7 +7,7 @@ module.exports = function (RED) { function PrometheusMetricConfigNode(config) { RED.nodes.createNode(this, config); let node = this; - RED.log.debug('Instanciating PrometheusMetricConfigNode', node.id); + RED.log.info('Instanciating PrometheusMetricConfigNode ' + config.name); node.name = config.name; node.help = config.help; @@ -20,6 +20,7 @@ module.exports = function (RED) { } this.on('close', function () { + RED.log.info('Closing PrometheusMetricConfigNode ' + config.name); try { exporter.removeMetric(node.name); } catch (error) { @@ -29,6 +30,7 @@ module.exports = function (RED) { } function registerMetric(node) { + RED.log.info('PrometheusMetricConfigNode.registerMetric ' + node.name); let labelsList = undefined; if (node.labels) { let splitLabels = node.labels.split(',');