Node-RED Health Monitoring

Hi,
I would like to monitor health of Node-red on 24*7 basis using a script. Is there any flag/tags/api available in Node-red , which I can access or consume in program and keep on polling Node-red's health.

Thanks

If node-red is down you cannot use node-red to check its health.

You can use netstat -an | grep -c 1880.
if > 0, node-red is up.

Another method would be to use a heart beat method, use a flow to create either a file, MQTT message, etc. on a regular base, if the file date is older than your heat beat interval then you know something amiss.

Search this forum for the word watchdog. There has been lots of discussion on heath of node-red/pi. Might give you some ideas or save you some time.

This is what I do. Much simpler and more robust than the watchdog method.

As I have 2 Pi's, both run Node-RED, MQTT, Grafana and InfluxDB. Both Node-RED's post MQTT heartbeats to both MQTT brokers, the MQTT LWT is used so that if Node-RED stops working, the broker changes the message to "Offline". Node-RED posts an "Online" value every minute.

1 Like

Thanks all for your valuable response. If I drill down to health of specific flow in node-red,then what would be the best option ?

Solution: Thought up to hit node-red rest admin api i.e http://node-red-ip:1880/flow/flow-id, if it returns 200 ok response, then flow is healthy, else flow stopped working.

please validate above solution or propose best solution. :slight_smile:

Maybe use the status node...

The flow I mentioned does the trick and results in a report even when NR dies or indeed if the Pi dies (since I have the 2nd Pi also reporting). It also requires nothing more than Node-RED and MQTT - and a 2nd Pi of course, that could easily be a Pi Zero though.

Hitting up the url would need to be done from yet another piece of software - which could be a 2nd Node-RED.