Aggregate values to show "per time period"?

I have an eventsource posting values to NodeRED. I want to show some metrics in a dashboard:

  • Events per minute for the last hour
  • Events per hour for the last day
  • Average value (each event comes with a measurement) per minute/hour

What’s a good way to aggregate? Would I use the context/flow/global object for that or something else?

How about saving them to a database and aggregate from the database?

Thx for the reply. Appreciate the time taken.
Database is the plan B. Though for just a few values (60 & 24) in memory would do (and would be fast).
Also found this:
Seem to do the trick

1 Like

This ode you pointed seems to do something very similar to the standard palette smooth node, I don’t know what is the difference.

If you wanted to make something really easy you can do it with a simple counter and reset every hour or at a specific time, (maybe having various running) however this will give you the messages since a specific time, for instance since 00:00 or since 13:00 or whatever, not exactly latest 60 minutes.


FYI - I have raised following feature request :
for node-red-contrib-aggregator

Once implemented, this should give an even more real time view of the running average or running total over a configurable period.

In case the messages are arriving at fixed rate (e.g. once every 10 seconds) then node-red-node-smooth can be used.