NodeRed health detection

Hello,

While using tools like kubernetes to deploy NodeRed instances, we need to provide probe endpoints for health check.

While having NodeRed editor enabled, we can check its health with a simple http get on / endpoint. (will get the editor interface html file)

But once we disabled the editor, this health check no longer work.

Other than manually create a health check endpoint in NodeRed, is there another way to do health check while having editor disabled or not?

I also saw that, in the config file, we can use a http middleware. But after some simple test, this middleware is only applied/invoked, when an given http url exists in NodeRed as endpoint, otherwise, nothing happened.

Any suggestion ?

Thanks

Hi @jacyuan

you are right to observe if you disable the editor you disable all of the admin endpoints. You would need to introduce your own endpoint for your health check. If you are running node-red embedded in your own Node app, you could easily add your own route to the server to handle the health check.

The httpNodeMiddleware option applies the middleware to the routes defined by HTTP In nodes in your flow. Does that answer you question?

Interesting topic,

  • What is a high quality and "good enough" reliable response to a health check of NR?

Personally, I would create a service outside of NR that is checking if NR "is alive". The question is what is really enough? Is it enough that a flow is running? Or that the NR process can be found in the process list? Or is it enough that NR responds correctly to a request?

Currently I have written services that sends a request to NR via MQTT and if I receive the expected response, all is fine

But if also the flow is stopped if the editor is disabled, then my solution will not work

and that will tell you the Pi is not healthy :stuck_out_tongue_closed_eyes:

Hi @knolleary, hi @krambriw thanks for your reply.

Since we try to make things reusable with less modifications and dependencies, I found some other alternatives currently.

I saw the use of "httpStatic" configuration that gives possibility to hold a static folder.
And this endpoint is still enabled even when the editor has been disabled.

So the current solution that I've adapted consists of adding a simple file into this static folder, and using its url as the health check point.

Since currently, our health check is used only for detecting whether the NodeRed has been launched correctly or not, but not a business logic check of the inside flow. This seems do the trick :slight_smile:

2 Likes

Similar solution I am looking for. Could you please share the service which send mqtt request and poll NR health.

Thanks