On this page



Enables, disables, or configures the Database Profiler. The profiler captures and records data on the performance of write operations, cursors, and database commands on a running mongod instance.

The profiler is off by default.


Profiling can impact performance and shares settings with the system log. Carefully consider any performance and security implications before configuring and enabling the profiler on a production deployment.

See Profiler Overhead for more information on potential performance degradation.

The profile command has the following syntax:

  profile: <level>,
  slowms: <threshold>,
  sampleRate: <rate>
Field Type Description
profile int

Default: 0

Specifies which operations should be profiled.
The following profiler levels are available:
Level Description
-1 Returns the current profiler level, but does not change it.
0 Turns the profiler off so that it does not collect any data. This is the default profiler level.
1 Sets the profiler to collect data for operations that take longer than the value of slowms.
2 Sets the profiler to collect data for all operations.
slowms int

Optional. Default: 100

The slow operation time threshold, in milliseconds. Operations that run for longer than this threshold are considered slow.

The system log and profiler are configured separately but share the same settings for slowms and sampleRate. When logLevel is set to 0, mongod records slow queries to the system log at a rate determined by slowOpSampleRate. At higher logLevel settings, all queries appear in the system log regardless of their latency.


This argument affects the same setting as the configuration option slowOpThresholdMs.

sampleRate double

Optional. Default: 1.0

The fraction of slow operations that should be profiled.
sampleRate accepts values between 0 and 1, inclusive.


This argument affects the same setting as the configuration option slowOpSampleRate.

New in version 3.6.

The db.getProfilingStatus() and db.setProfilingLevel() shell methods provide wrappers around the profile command.


The profile command obtains a write lock on the affected database while enabling or disabling the profiler. This is typically a short operation. The lock blocks other operations until the profile command has completed.

See also

Database Profiling.

←   ping serverStatus  →