M103: Chapter 1: Lab - Logging to a Different Facility

I completed the lab successfully, however, I have a question concerning the “operationProfiling” section of the config file.

If I do not include:

mode: “slowOp”

then wouldn’t Profiling default to “off” and then wouldn’t my “slowOpThresholdMs” setting be ineffective, in that there would be no profiling regardless of operation time? Or am I misunderstanding the function of “mode”?

The detailed answer for the lab did not include the line:
mode: “slowOp”

Thank you!

1 Like

Hi,
I think you’re right, if you don’t set the mode to slowOp there’s no profiling.
This can be verified after starting the mongod process with:

db.getProfilingLevel()

Maybe it’s an oversight?

The database profiler and the process log vary in verbosity and in some cases, content.

Here’s my understanding.

Process Log features:

  • Logs are written to --logpath or to the console
  • Cannot directly query the log using find() or aggregate()
  • operationProfiling.mode(off) or db.setProfilingLevel(0) and setLogLevel(1 to 5)
  • slowms and sampleRate still apply. Meaning it will log diagnostic logs based on these two settings.
  • Note, slow queries still get logged but not at the level of granularity that the Database Profiler provides. These slow queries will come under the COMMAND status in the log file.

Database Profiler features:

  • Logs are written to the system.profile collection
  • Can query the log using find() or aggregate()
  • operationProfiling.mode("slowOp" | all) or db.setProfilingLevel(1 | 2)
  • slowms and sampleRate apply. Meaning it will log database logs based on these two settings but with increased verbosity.

As you can see, even though the profiling level is off or 0, diagnostic logs are still written to the log file based on the slowms and sampleRate settings.

Therefore, this ticket is about logging any process that takes 50ms and re-routing these diagnostic logs to a log file. The word “query” confuses things!

1 Like