To change the threshold, pass two parameters to the db.setProfilingLevel() helper in the mongo shell. The first parameter sets the profiling level for the current database, and the second sets the default slow operation threshold for the entire mongod instance . 

For example, the following command sets the profiling level for the current database to 0 , which disables profiling, and sets the slow-operation threshold for the mongod instance to 20 milliseconds. Any database on the instance with a profiling level of 1 will use this threshold: 

db.setProfilingLevel(0,20) 

Check Profiling Level To view the profiling level (page 228), issue the following from the mongo shell: 

db.getProfilingStatus() 

The shell returns a document similar to the following: 

{ "was" : 0, "slowms" : 100 } 

The was field indicates the current level of profiling. 

The slowms field indicates how long an operation must exist in milliseconds for an operation to pass the “slow” threshold. MongoDB will log operations that take longer than the threshold if the profiling level is 1 . This document returns the profiling level in the was field. For an explanation of profiling levels, see Profiling Levels (page 228). 

To return only the profiling level, use the db.getProfilingLevel() helper in the mongo as in the following: 

db.getProfilingLevel() 

Disable Profiling To disable profiling, use the following helper in the mongo shell: 

db.setProfilingLevel(0) 

Enable Profiling for an Entire mongod Instance For development purposes in testing environments, you can enable database profiling for an entire mongod instance. The profiling level applies to all databases provided by the mongod instance. 

To enable profiling for a mongod instance, pass the following parameters to mongod at startup or within the configuration file : 

mongod --profile=1 --slowms=15 

This sets the profiling level to 1 , which collects profiling data for slow operations only, and defines slow operations as those that last longer than 15 milliseconds. 

## See also: 

mode and slowOpThresholdMs . 

Database Profiling and Sharding You cannot enable profiling on a mongos instance. To enable profiling in a shard cluster, you must enable profiling for each mongod instance in the cluster. 

## View Profiler Data 

The database profiler logs information about database operations in the system.profile (page 291) collection. 

