How to get MongoDB slow queries in a file

1,423 views
Skip to first unread message

Sayta Dommeti

unread,
Jun 6, 2014, 3:10:38 AM6/6/14
to mongod...@googlegroups.com

Hi All,

I have installed MongoDB instances along with replication.

I would like to know the list of slow queries running in mongodb server.

1) Is it possible to log all slow queries in a file?

We can get find out slow queries by enable Profiling for each database individually in system.profile collection 
  
Actually, we have more than 10 databases.

2) How to log  slow queries of all databases in a single collection ?

Best Regards,
Satya D
 
  
 

Tim Hawkins

unread,
Jun 6, 2014, 3:14:23 AM6/6/14
to mongod...@googlegroups.com

enable systemprofiling in mongo, it will create a system,profile collection with a document for each query that took more than a configured number of milliseconds. if you need it as text you can export it using mongoexport.

Tim Hawkins - obsesive code hacker, its a character flaw......

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/7451b9f2-9b93-48b3-8415-0b317e7b3f96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Zola

unread,
Jun 6, 2014, 4:31:38 PM6/6/14
to mongod...@googlegroups.com
Hi Satya!

1) Slow queries (by default, those taking longer than 100 ms) are logged in the 'mongod' log file.  You can find this file by logging in with the 'mongo' shell and running the command:

> db.serverCmdLineOpts().parsed

Look for the 'dbPath' field.  Note that each individual 'mongod' process will log operations separately.    In Support, we use the 'mtools' package extensively to analyze log files, you can find it at https://github.com/rueckstiess/mtools

2) Unfortunately, there's no way to get MongoDB to log the slow queries of all databases in a single collection.

 -William 

vrp...@gmail.com

unread,
May 16, 2016, 11:03:44 PM5/16/16
to mongodb-user, willia...@10gen.com
Hi William,

There are ways to to get slow queries across multiple db instances into a single view. I'm using https://worktheme.com for this. You can add multiple instances, find query patterns, slow queries etc.

Wish they could add more features, but it is just enough for my needs.

-vb
Reply all
Reply to author
Forward
0 new messages