diff --git a/README.md b/README.md index 425045e..4d69625 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,12 @@ Choose the `op` property from one of the following values: * For metrics of type __Counter__: * `inc` - Increases the counter by `val` (without specifying `val`, defaults to `1`) + * `remove` - Remove the stored value * For metrics of type __Gauge__: * `set` - Sets the gauge to `val` (which is mandatory for this operation) * `inc` - Increases the gauge by `val` (without specifying `val`, defaults to `1`) * `dec` - Decreases the gauge by `val` (without specifying `val`, defaults to `1`) + * `remove` - Remove the stored value As described above, the `val` property is mandatory or optional depending on the selected `op` and the metric type. diff --git a/prometheus-exporter/prometheus-exporter.html b/prometheus-exporter/prometheus-exporter.html index b3401ab..3155c3b 100644 --- a/prometheus-exporter/prometheus-exporter.html +++ b/prometheus-exporter/prometheus-exporter.html @@ -37,6 +37,7 @@

Using the metric in a flow

  • For metrics of type Gauge: @@ -46,6 +47,7 @@

    Using the metric in a flow

    to 1)
  • dec - Decreases the gauge by val (without specifying val, defaults to 1)
  • +
  • remove - Remove the stored value
  • @@ -101,4 +103,4 @@

    Check the metrics output

    label: label, paletteLabel: 'prometheus out' }); - \ No newline at end of file + diff --git a/prometheus-exporter/prometheus-exporter.js b/prometheus-exporter/prometheus-exporter.js index 1470a08..8d323c3 100644 --- a/prometheus-exporter/prometheus-exporter.js +++ b/prometheus-exporter/prometheus-exporter.js @@ -1,6 +1,6 @@ const VALID_OPS = { - counter: ['inc'], - gauge: ['inc', 'dec', 'set'] + counter: ['inc', 'remove'], + gauge: ['inc', 'dec', 'set', 'remove'] }; const DEFAULT_OPS = { @@ -37,8 +37,8 @@ module.exports = function (RED) { } // apply specific value if (msg.payload.val === undefined || msg.payload.val === null) { - // no value is only allowed for counter - if (this.metricConfig.mtype !== 'counter') { + // no value is only allowed for counter or remove op + if (this.metricConfig.mtype !== 'counter' && metricOp !== 'remove') { done('Missing val for metric type ' + this.metricConfig.mtype); } } else {