[SERVER-5266] Make a clearer API for configuring global slowms Created: 09/Mar/12  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Logging
Affects Version/s: 2.0.3
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Jared D. Cottrell Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 2
Labels: logging, profiling, setParameter
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-4785 slowms should be per database for pro... Backlog
Related
is related to SERVER-11125 setProfilingLevel() does not accept z... Closed
is related to SERVER-6978 getParameter should know all setParam... Closed
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Participants:
Case:

 Description   

Allow changing the threshold for logging slow queries.

http://www.mongodb.org/display/DOCS/setParameter+Command



 Comments   
Comment by Asya Kamsky [ 07/Sep/18 ]

You can set slowMs globally via 

db.setProfilingLevel(db.getProfilingLevel(), <new-ms-threshold>) 

This may not have worked in the past but works currently. 0 as first parameter indicates that no profiling should be done, and ms threshold can be specified as 0 or even -1 to log all operations.

Example:

> db.setProfilingLevel(db.getProfilingLevel(), 1)
{ "was" : 0, "slowms" : 10, "sampleRate" : 1, "ok" : 1 }
> db.setProfilingLevel(db.getProfilingLevel(), 10)
{ "was" : 0, "slowms" : 1, "sampleRate" : 1, "ok" : 1 }
> db.setProfilingLevel(db.getProfilingLevel(), -1)
{ "was" : 0, "slowms" : 10, "sampleRate" : 1, "ok" : 1 }
> db.setProfilingLevel(db.getProfilingLevel(), 10)
{ "was" : 0, "slowms" : -1, "sampleRate" : 1, "ok" : 1 }

To see current slowms setting use

> db.getProfilingStatus()
{ "was" : 0, "slowms" : 10, "sampleRate" : 1 }
> db.getProfilingStatus().slowms
10
> db.runCommand({profile:-1})
{ "was" : 0, "slowms" : 10, "sampleRate" : 1 }

Comment by Asya Kamsky [ 24/Jan/18 ]

We would like to make changes in SERVER-4785 to allow setting profiling for one DB only, so re-opening this ticket to track setting global slowms threshold.

Comment by Mike Zraly [ 23/Mar/17 ]

Well shoot, I was hoping to be able to simplify provisioning of test environments by specifying the threshold in the mongod.conf file so that I can use the canned init.d service scripts. Thanks for getting back to me.

Comment by Mira Carey [ 23/Mar/17 ]

It's possible to set the slowms threshold in a running server by issuing profile commands. These can be issued either with db.setProfilingLevel, or by manually running the command.

The below samples will alter slowms without changing the profiling level

// manually in one step
db.runCommand({profile:-1, slowms: desired_slowms_value});
 
// with db helpers
db.setProfilingLevel(db.getProfilingLevel(), desired_slowms_value);

While a setParameter would be more in line with current database features, we consider the current functionality sufficient.

Comment by Scott Hernandez (Inactive) [ 09/Mar/12 ]

Currently slowms is global and can be set using a pattern like this:

> db.setProfilingLevel(1,X)
> db.setProfilingLevel(0)

Generated at Thu Feb 08 03:08:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.