node-red-contrib-topic-frequencies

Computes frequencies of events per topic on a sliding interval.

Usage no npm install needed!

<script type="module">
  import nodeRedContribTopicFrequencies from 'https://cdn.skypack.dev/node-red-contrib-topic-frequencies';
</script>

README

Publish

Topic Frequencies

Computes frequencies of events per topic on a sliding interval.

This node is inspired by node-red-contrib-metric-per-topic

Documentation

Key features:

  • Passthrough node, capturing metrics and let original message pass through
  • Interval is sliding time window, allowing to report anytime and always have full interval data metrics
  • Ability to specify topic key and value key measured, as JSON dot path (e.g. payload.uniqueid)
  • Ability to specify report scheduler, distinct from interval used to measure frequencies
  • Ability to control few operations, like reset counters, which can be triggered by Input node

Example Flow

See documentation

Sample output:

{
    "topics": {
        "toto": {
            "sum": 450,
            "avg": 6.081081081081081,
            "min": 5,
            "max": 15,
            "elements": 74
        },
        "titi": {
            "sum": 40,
            "avg": 10,
            "min": 10,
            "max": 10,
            "elements": 4
        },
        "<all>": {
            "sum": 490,
            "avg": 6.282051282051282,
            "min": 5,
            "max": 15,
            "elements": 78
        }
    },
    "cycles": 2476,
    "interval": 1,
    "units": "minutes",
    "topicKey": "payload.uniqueid",
    "valueKey": "payload.temp",
    "_msgid": "b1bb6c79.43cb4"
}