Easy Tutorial
❮ Home Mongodb Regular Expression ❯

MongoDB Monitoring

After you have installed and deployed MongoDB and started the MongoDB service, you must understand the runtime status of MongoDB and monitor its performance. This ensures that MongoDB can handle high traffic situations and operate normally.

MongoDB provides two commands, mongostat and mongotop, to monitor its runtime status.


mongostat Command

mongostat is a built-in status monitoring tool for MongoDB, used in the command line. It periodically fetches the current runtime status of MongoDB and outputs it. If you find that the database suddenly slows down or encounters other issues, you should consider using mongostat to check the status of MongoDB.

Start your Mongod service, navigate to the bin directory of your MongoDB installation, and then enter the mongostat command as shown below:

D:\set up\mongodb\bin>mongostat

The output of the above command is as follows:

mongotop Command

mongotop is another built-in tool for MongoDB. mongotop provides a method to track an instance of MongoDB and see where the majority of time is spent on reading and writing data. mongotop offers statistics at the collection level. By default, mongotop returns values every second.

Start your Mongod service, navigate to the bin directory of your MongoDB installation, and then enter the mongotop command as shown below:

D:\set up\mongodb\bin>mongotop

The output of the above command is as follows:

With Parameters Example

E:\mongodb-win32-x86_64-2.2.1\bin>mongotop 10

The 10 is the <sleeptime> parameter, which is optional. It specifies the waiting time in seconds between mongotop calls. By default, mongotop returns data every second.

E:\mongodb-win32-x86_64-2.2.1\bin>mongotop --locks

Reports the lock usage for each database using mongotop --locks, which produces the following output:

Output Field Explanation:

❮ Home Mongodb Regular Expression ❯