To monitor slow queries which are run in a mongodb database, profile attribute need to be set. There are three profiling levels: 0, 1 and 2. Add the following line into mongo.conf:
To monitor whole database, mongo.conf file could be edited. Set profile attribute to 1 or 2 and then restart mongod service :
If you don't want to monitor all databases but some, profiling level could be set for only these ones.
Select the database:
To clear system.profile collection, profiling needs to be stopped. Just set the level to 0. Then, call db.system.profile.remove(). Now, the collection is empty and profiling could be restarted.
profile=1
Value 0 disables profiling. Value 1 enables the system to detect and record slow queries which take more time than given threshold value. If the attribute is set to 2, information of all queries are recorded. To monitor whole database, mongo.conf file could be edited. Set profile attribute to 1 or 2 and then restart mongod service :
>sudo service mongod restart.
From now on, profiling is enabled. Slow query profiling data of each database will be stored in the collection named db.system.profile.If you don't want to monitor all databases but some, profiling level could be set for only these ones.
Select the database:
>use mydb
Set profiling level:>db.setProfilingLevel(1)
{ "was" : 0, "slowms" : 100, "ok" : 1 }
Slowms key refers to lower time threshold value which is 100 ms as default. It could be set by giving parameter to setProflingLevel function:>db.setProfilingLevel(1, 200)
{ "was" : 1, "slowms" : 100, "ok" : 1 }
Now, the threshold is set to 200 ms.To clear system.profile collection, profiling needs to be stopped. Just set the level to 0. Then, call db.system.profile.remove(). Now, the collection is empty and profiling could be restarted.
Tam aradigim bilgi..
ReplyDelete