Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
matterlobby committed Nov 11, 2020
2 parents 2f52da0 + 42bf8f0 commit 66e0292
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 7 additions & 3 deletions prometheus-exporter/prometheus-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 66e0292

Please sign in to comment.