# Ability to use hooks to listen to events on Start / Stop / Error of a Flow

**URL:** https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041
**Category:** Feature Requests
**Created:** [28 June 2024 11:35 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041 "2024-06-28T11:35:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sirohiwebdev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sirohiwebdev/32/92318_2.png) [@sirohiwebdev](https://discourse.nodered.org/u/sirohiwebdev)
#### Post date: [28 June 2024 11:35 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041/1 "2024-06-28T11:35:51Z")

</div>

Hey Team,  
I am looking for some solution to know when a flow started and ended.  
Something that allows you to use Hooks Api and listen for events like "onFlowStart" / "onFlowStop",  
This will help us monitor the flows and keep track of time taken for various flows which can later be used to identify slowness / flow execution rate etc.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 June 2024 11:41 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041/2 "2024-06-28T11:41:45Z")

</div>

Flows only really start and stop when Node-RED starts and stops. Other than that they are driven by events. So a trigger node creates a message that appears to "start" a flow but really, the flow has been running all along, just that it had no messages.

There are various ways therefore to track timings. Depends on the details.

---

<div class="post-metadata">

### Author: ![sirohiwebdev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sirohiwebdev/32/92318_2.png) [@sirohiwebdev](https://discourse.nodered.org/u/sirohiwebdev)
#### Post date: [10 July 2024 08:19 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041/3 "2024-07-10T08:19:17Z")

</div>

Thanks for your explanation.  
I want to track the timing and input/output of each node's send and receive calls, to store history for debugging.  
I am considering adding hooks on **onSend** and **onRecieve** to get the events and inject a correlation ID at the trigger node.  
Later I can relate this information based on correlation ID, flow ID, and node ID.  
I would like to know, whether this is a good approach, or something better is there.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [10 July 2024 11:29 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041/4 "2024-07-10T11:29:33Z")

</div>

> [@sirohiwebdev](#):
>
> I want to track the timing and input/output of each node's send and receive calls, to store history for debugging.

I think there is a contributed node for doing that? Can't find it in the flows but maybe a search through the forum will find it.

---

<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: [8 September 2024 11:30 UTC](https://discourse.nodered.org/t/ability-to-use-hooks-to-listen-to-events-on-start-stop-error-of-a-flow/89041/5 "2024-09-08T11:30:22Z")

</div>

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