In Mongodb 4.0, can i get slow queries information at mongod.log?

Hi. bros
I got problem to develop slow query monitoring system for MongoDB 4.0.

I want to use mongod.log and I don’t want to use system.profile collection to get slow query information.

how can i find slow query in mongod.log?
sorry for my bad english.
thank you for reading :slight_smile:

Hi @jeongmu.park

By default mongod will record queries slower than 100ms to the logs, which will be printed to stdout by default, or directed to a file using the --logpath option.

In later versions of MongoDB (6.0.4 in this example), it will look like this:

{"t":{"$date":"2023-03-08T13:50:43.571+11:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn613","msg":"Slow query" ....

In 4.0 this may look a bit different, but since the 4.0 series was not supported anymore as per April 2022 I would encourage you to upgrade to a supported version.

This slow query threshold can be customized using the db.setProfilingLevel() command.

Best regards

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.