Вопрос

I have several node services running, each using a Mongoose driver. I have Nagios warnings setup for too many queries per second, and these have started to fire lately. What's the best way to track down which service is blasting all the queries?

Это было полезно?

Решение

I'd log into the mongo shell when this is happening and run db.currentOp(true):

http://docs.mongodb.org/manual/reference/method/db.currentOp/

Don't know your specific setup but if you have multiple clients hitting the database the currentOp.client field in the results is very useful in tracking down the source of rogue queries.

Другие советы

first, you can use profiling:

db.setProfilingLevel(level, slowms)

This will write to the queries that takes more than "slowms" into system.profile collection.
Note profiling itself will slow down your system. So try not to do it in peak hours. And be careful with the slowms parameter so that you don't record too many queries.

Secondly, have a look at your log:

tail -f /var/log/mongodb.log

It will record slow queries.

EDIT: if you are looking for which client sends most queries, try mongotop which will give you a per collection read/write overview. Or mongostate which will give you a per database overview. It's not that straight forward, but it helps you to analyse the stress. Or you can have a look at the network traffic with Linux tool iftop.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top