Database Reference
In-Depth Information
Enabling and configuring the profiler
To enable, configure, and use the profiler engine, open a mongo shell interface. Using this
environment, you can enable the profiler engine or even get the profiler log from the data-
base.
The structure of the setProfilingLevel function is as follows:
db.setProfilingLevel(level, slowms)
The first parameter is the level of the profiler, which is a mandatory parameter. The second
and optional parameter, slowms , is the threshold in milliseconds to consider an operation
as a slow operation.
In order to enable the profiler for a single database, you can simply use the following com-
mand in the mongo shell interface:
db.setProfilingLevel(2)
For instance, the preceding command enables the profiler and sets the profiler verbosity to
the highest level. The profiler will collect all operation logs and save them in the sys-
tem.profile collection.
It is worth mentioning that by using the following command, you can set both the level and
the slowOpThresholdMs option at the same time for a database:
db.setProfilingLevel(1, 50)
The preceding command sets the profiling level to 1 and configures the
slowOpThresholdMs option to 50 ms.
To disable the profiler engine, use following command:
db.setProfilingLevel(0)
To get the current profiler status, you can use the following command in the mongo shell:
db.getProfilingStatus()
The output of the preceding command should look like the following screenshot:
Search WWH ::




Custom Search