Mongoid server status used for health check

Hello,
I am using Mongoid > 5.0 in my Rails Application. I am implementing a health check endpoint where I need to check my database server status.
I tried to find the right way to do this. I see Mongo offers a Ping command but its part of Administration and not accessible to my application user. Among all the APIs listed on mongoid doc and Ruby Mongo doc
So one way I’ve figured out to do this is using Mongoid.default_client.database.list_collections time out by this API is currently an indication of down status for me.
Wanted to know the community ideas about this.
Your help is much appreciated.

You should always be able to send {ismaster:1} to get a reply from the server.

1 Like