diff --git a/README.md b/README.md index 15d44f4..eb511b0 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ Alternatively, you can also manually install the node permanently into your embe npm install node-red-contrib-prometheus-exporter ``` -*Note: Until we have officially released the library, it needs to be installed via downloading this repository into your project.* - ## How to use ### Configure a metric diff --git a/package.json b/package.json index c188d0c..61241a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-prometheus-exporter", - "version": "1.0.0", + "version": "1.0.1", "description": "A NodeRED node which allows exporting Prometheus metrics from within flows.", "keywords": ["node-red", "prometheus", "telegraf"], "main": "index.js", diff --git a/prometheus-exporter/prometheus-exporter.js b/prometheus-exporter/prometheus-exporter.js index f325af2..1470a08 100644 --- a/prometheus-exporter/prometheus-exporter.js +++ b/prometheus-exporter/prometheus-exporter.js @@ -36,13 +36,17 @@ module.exports = function (RED) { metricOp = DEFAULT_OPS[this.metricConfig.mtype]; } // apply specific value - if (Number.isInteger(msg.payload.val)) { - metricVal = msg.payload.val; - } else { + if (msg.payload.val === undefined || msg.payload.val === null) { // no value is only allowed for counter if (this.metricConfig.mtype !== 'counter') { done('Missing val for metric type ' + this.metricConfig.mtype); } + } else { + if (isNaN(Number(msg.payload.val))) { + done('Invalid val for metric type ' + this.metricConfig.mtype); + } else { + metricVal = Number(msg.payload.val); + } } // apply labels if (msg.payload.labels) {