MongoDB Documentation, Release 3.0.4 To view profiling information, query the system.profile (page 291) collection. You can use $comment to add data to the query document to make it easier to analyze data from the profiler. To view example queries, see Profiler Overhead (page 231). For an explanation of the output data, see Database Profiler Output (page 292). Example Profiler Data Queries This section displays example queries to the system.profile (page 291) col- lection. For an explanation of the query output, see Database Profiler Output (page 292). To return the most recent 10 log entries in the system.profile (page 291) collection, run a query similar to the following: db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty() To return all operations except command operations ( $cmd ), run a query similar to the following: db.system.profile.find( { op: { $ne : 'command' } } ).pretty() To return operations for a particular collection, run a query similar to the following. This example returns operations in the mydb database’s test collection: db.system.profile.find( { ns : 'mydb.test' } ).pretty() To return operations slower than 5 milliseconds, run a query similar to the following: db.system.profile.find( { millis : { $gt : 5 } } ).pretty() To return information from a certain time range, run a query similar to the following: db.system.profile.find( { ts : { $gt : new ISODate("2012-12-09T03:00:00Z") , $lt : new ISODate("2012-12-09T03:40:00Z") } } ).pretty() db.system.profile.find( { ts : { $gt : new ISODate("2011-07-12T03:00:00Z") , $lt : new ISODate("2011-07-12T03:40:00Z") } }, { user : 0 } ).sort( { millis : -1 } ) The following example looks at the time range, suppresses the user field from the output to make it easier to read, and sorts the results by how long each operation took to run: Show the Five Most Recent Events On a database that has profiling enabled, the show profile helper in the mongo shell displays the 5 most recent operations that took at least 1 millisecond to execute. Issue show profile from the mongo shell, as follows: show profile Chapter 5. Administration 230