# Count number of messages in the last 10 minutes

**URL:** https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587
**Category:** General
**Created:** [16 February 2024 10:50 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587 "2024-02-16T10:50:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Poeschie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/poeschie/32/88341_2.png) [@Poeschie](https://discourse.nodered.org/u/Poeschie)
#### Post date: [16 February 2024 10:50 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587/1 "2024-02-16T10:50:50Z")

</div>

Hi,  
i'm stuck with following problem.  
I get incoming messages of a a "tcp in" node from a keyence vision system if this system detects an error.  
And i want to send a message via telegram if there are 6 errors in the last 10 minutes.

My idea is to create an array 0-9. Now i count the incoming errors every minute to array[0]. Also i shift the array every minute so array[8] goes to array[9] and array[7] goes to array[8] ... and array[0] is set to 0.

Is this the right direction or is there an easier way?

EDIT: I just found this node which is eventually suitable: [node-red-contrib-msg-speed (node) - Node-RED (nodered.org)](https://flows.nodered.org/node/node-red-contrib-msg-speed)

So i change my question: Is my idea a good way if i want to solve my problem with the function node?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [16 February 2024 11:08 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587/2 "2024-02-16T11:08:27Z")

</div>

> [@Poeschie](#):
>
> i want to send a message via telegram if there are 6 errors in the last 10 minutes.

Can that be turned round the other way and instead send the message after 10 minutes if there is not a good signal in that interval? That would be much easier to implement, using just a Trigger node.

---

<div class="post-metadata">

### Author: ![Poeschie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/poeschie/32/88341_2.png) [@Poeschie](https://discourse.nodered.org/u/Poeschie)
#### Post date: [16 February 2024 11:12 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587/3 "2024-02-16T11:12:07Z")

</div>

Unfortunately not, because sometimes the mashine is turned off or paused.

But i use this method already for a different solution. Basically it works like a watchdog.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [16 February 2024 11:15 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587/4 "2024-02-16T11:15:43Z")

</div>

Is there no way of knowing that the machine is turned off or paused?

If not then you will have to implement something along the lines you have suggested.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [16 May 2024 11:16 UTC](https://discourse.nodered.org/t/count-number-of-messages-in-the-last-10-minutes/85587/5 "2024-05-16T11:16:17Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
