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.

2 Likes

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.

Sorry for reviving this years old topic, but do you still have a version of this flow/s you could share? I was about to create the same thing but figured I may as well search for existing solutions here first.

'Fraid not Harold. My Pi's are long retired as I switched to a single old laptop instead.

Shouldn't be too hard to do though.

Just to throw another idea in, I use the free version of this website https://healthchecks.io

I use this to check that a PI at 3 different locations is still alive.

Every 10 minutes one of my flows sends a http request to their site. If these requests are not seen for a time period (configurable) then the alarm is raised. I use email and telegram to do this, but many other methods are available.

No connection to the site, but I have used it for about 4 years now, and it’s proved very reliable.

Honestly, I use Telegraf to monitor my home server. It logs to InfluxDB but is set up to also output to MQTT. I can set up alarms in both Node-RED (looking at MQTT) AND in Grafana (looking at the InfluxDB data).

I generally don't bother with Grafana alarms though. Because my live Node-RED instance is generally very reliable, I use it to keep an eye on things. Important failures are forwarded to Telegram so I see it on my phone. I also have a visual dashboard (using UIBUILDER of course :slight_smile: )

Hovering over the coloured status bar tells me when it was last updated. The main card is clickable if the device/service has its own web interface so I can go straight to it.

1 Like