Reporting with Nodered

I would like to collect some data from nodered flows.
One type of data is the flow starting and finishing.
I'd mention that I'd like to collect my data in Azure ApplicationInsights - but maybe this is not that important.
can I do this somehow automatically - so integrate this information sending to happen at every flow starting, finishing or I'll have to have my specialized, nodes that will have to be integrated in the flows?

Welcome to the forum @en-andreea-anastases

What do you mean by a flow starting?

If you set the logging level to "trace" in settings.js, as well as a huge quantity of other stuff it will log flow starts like this

 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4] start flow [ce2c31fd397862f4]
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4] ------------------|--------------|-----------------
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  id               | type         | alias
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4] ------------------|--------------|-----------------
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  cdb05bd5b723525d | inject       |
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  c8f1854f6cb475a7 | comment      |
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  41a50d1c12fd88a5 | change       |
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  4de220888ed3f823 | debug        |
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4]  eeaeb90c363df0cc | debug        |
 5 Oct 08:07:33 - [trace] [flow:ce2c31fd397862f4] ------------------|--------------|---------------

You could filter "start flow" lines from the log.
It's not so easy to define a flow stopping.

1 Like

You could also create a custom logging function in settings.js that only takes the data you are interested in. For example, I have one that takes trace-level data for one node type and only warn/error for everything else.

1 Like

as a flow (meaning a set of interconnected nodes) is triggered and the execution of the individual nodes start.
i am/was looking for a generic way to intercept that moment, in order to log that so on

This is only possible if the nodes output something logable.

If you turn up Node-RED's logging to TRACE level, you will see all the events that the log receives. It is a LOT! A custom log lets you filter that down to something manageable.

If the nodes are your own custom ones, then it is trivial to add appropriate log outputs at runtime using RED.log. As in RED.log.trace('[uibuilder:myfunction] Function started')

Or use the Flogger node and put it in parallel with whatever triggers your flow and have it output to a different logfile per flow

Then have a flogger node at the end of the flow to signal when it has finished.

You could also use Barts timing nodes for tracking messages through the flow and send that output to the flogger nodes

I use the flogger nodes a lot in my system as they have log file management and rollover etc.

I will often dump the global context into one when try to track down issues or get insights as to what a node is attempting to act on

Craig

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