{"id":11144,"date":"2019-03-09T21:54:04","date_gmt":"2019-03-09T21:54:04","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11144"},"modified":"2019-03-09T21:54:04","modified_gmt":"2019-03-09T21:54:04","slug":"6-useful-tools-to-monitor-mongodb-performance","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/09\/6-useful-tools-to-monitor-mongodb-performance\/","title":{"rendered":"6 Useful Tools to Monitor MongoDB Performance"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/udemy-images.udemy.com\/course\/750x422\/1906852_93c6.jpg\" alt=\"Image result for mongodb images\" \/><\/p>\n<p>We recently showed how to install\u00a0<a href=\"https:\/\/www.tecmint.com\/install-mongodb-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noopener\">MongoDB in Ubuntu 18.04<\/a>. Once you have successfully deployed your database, you need to monitor its performance while it is running. This is one of the most important tasks under database administration.<\/p>\n<p>Luckily enough,\u00a0<strong>MongoDB<\/strong>\u00a0provides various methods for retrieving its performance and activity. In this article, we will look at monitoring utilities and database commands for reporting statistics about the state of a running MongoDB instance.<\/p>\n<h3>1. Mongostat<\/h3>\n<p><strong>Mongostat<\/strong>\u00a0is similar in functionality to\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-performance-monitoring-with-vmstat-and-iostat-commands\/\" target=\"_blank\" rel=\"noopener\">vmstat monitoring tool<\/a>, which is available on all major Unix-like operating systems such as Linux, FreeBSD, Solaris as well as MacOS.\u00a0<strong>Mongostat<\/strong>\u00a0is used to get a quick overview of the status of your database; it provides a dynamic real-time view of a running\u00a0<strong>mongod<\/strong>\u00a0or\u00a0<strong>mongos<\/strong>\u00a0instance. It retrieves the counts of database operations by type, such as insert, query, update, delete and more.<\/p>\n<p>You can run\u00a0<strong>mongostat<\/strong>\u00a0as shown. Note that if you have authentication enabled, put the user password in single quotes to avoid getting an error, especially if you have special characters in it.<\/p>\n<pre>$ mongostat -u \"root\" -p '=@!#@%$admin1' --authenticationDatabase \"admin\"\r\n<\/pre>\n<div id=\"attachment_30123\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Performance.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30123\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Performance.png\" sizes=\"auto, (max-width: 1232px) 100vw, 1232px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Performance.png 1232w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Performance-768x191.png 768w\" alt=\"Monitor MongoDB Performance\" width=\"1232\" height=\"306\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Monitor MongoDB Performance<\/p>\n<p>For more\u00a0<strong>mongostat<\/strong>\u00a0usage options, type the following command.<\/p>\n<pre>$ mongostat --help \r\n<\/pre>\n<h3>2. Mongotop<\/h3>\n<p><strong>Mongotop<\/strong>\u00a0also provides a dynamic real-time view of a running MongoDB instance. It tracks the amount of time a MongoDB instance spends reading and writing data. It returns values every second, by default.<\/p>\n<pre>$ mongotop -u \"root\" -p '=@!#@%$admin1'  --authenticationDatabase \"admin\"\r\n<\/pre>\n<div id=\"attachment_30124\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Activity.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30124\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Activity.png\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Activity.png 912w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/07\/Monitor-MongoDB-Activity-768x306.png 768w\" alt=\"Monitor MongoDB Activity\" width=\"912\" height=\"363\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Monitor MongoDB Activity<\/p>\n<\/div>\n<p>For more\u00a0<strong>mongotop<\/strong>\u00a0usage options, type the following command.<\/p>\n<pre>$ mongotop --help \r\n<\/pre>\n<h3>3. serverStatus Command<\/h3>\n<p>First, you need to run the following command to login into\u00a0<strong>mongo<\/strong>\u00a0shell.<\/p>\n<pre>$ mongo -u \"root\" -p '=@!#@%$admin1' --authenticationDatabase \"admin\"\r\n<\/pre>\n<p>Then run the\u00a0<strong>serverStatus<\/strong>\u00a0command, which provides an overview of the database\u2019s state, by collecting statistics about the instance.<\/p>\n<pre>&gt;db.runCommand( { serverStatus: 1 } )\r\nOR\r\n&gt;db.serverStatus()\r\n<\/pre>\n<h3>4. dbStats Command<\/h3>\n<p>The\u00a0<strong>dbStats<\/strong>\u00a0command returns storage statistics for a particular database, such as the amount of storage used, the quantity of data contained in the database, and object, collection, and index counters.<\/p>\n<pre>&gt;db.runCommand({ dbStats: 1 } )\r\nOR\r\n&gt;db.stats()\r\n<\/pre>\n<h3>5. collStats<\/h3>\n<p><strong>collStats<\/strong>\u00a0command is used to collect statistics similar to that provided by\u00a0<strong>dbStats<\/strong>\u00a0on the collection level, but its output includes a count of the objects in the collection, the size of the collection, the amount of disk space consumed by the collection, and information concerning its indexes.<\/p>\n<pre>&gt;db.runCommand( { collStats : \"aurthors\", scale: 1024 } )\r\n<\/pre>\n<h3>6. replSetGetStatus Command<\/h3>\n<p>The\u00a0<strong>replSetGetStatus<\/strong>\u00a0command outputs the status of the replica set from the perspective of the server that processed the command. This command must be run against the\u00a0<strong>admin<\/strong>\u00a0database in the followiing form.<\/p>\n<pre>&gt;db.adminCommand( { replSetGetStatus : 1 } )\r\n<\/pre>\n<p>In this addition to the above utilities and database commands, you can also use supported third party monitoring tools either directly, or via their own plugins. These include\u00a0<a href=\"https:\/\/www.tecmint.com\/install-mtop-mysql-database-server-monitoring-in-rhel-centos-6-5-4-fedora-17-12\/\" target=\"_blank\" rel=\"noopener\">mtop<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/install-munin-network-monitoring-in-rhel-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">munin<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.tecmint.com\/install-nagios-in-linux\/\" target=\"_blank\" rel=\"noopener\">nagios<\/a>.<\/p>\n<p>For more information, consult:\u00a0<a href=\"https:\/\/docs.mongodb.com\/manual\/administration\/monitoring\/\" target=\"_blank\" rel=\"nofollow noopener\">Monitoring for MongoDB Documentation<\/a>.<\/p>\n<p>That\u2019s it for now! In this article, we have covered some useful monitoring utilities and database commands for reporting statistics about the state of a running MongoDB instance. Use the feedback form below to ask any questions or share your thoughts with us.<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p><a href=\"https:\/\/www.tecmint.com\/monitor-mongodb-performance\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently showed how to install\u00a0MongoDB in Ubuntu 18.04. Once you have successfully deployed your database, you need to monitor its performance while it is running. This is one of the most important tasks under database administration. Luckily enough,\u00a0MongoDB\u00a0provides various methods for retrieving its performance and activity. In this article, we will look at monitoring &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/09\/6-useful-tools-to-monitor-mongodb-performance\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;6 Useful Tools to Monitor MongoDB Performance&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11144","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11144"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11144\/revisions"}],"predecessor-version":[{"id":11145,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11144\/revisions\/11145"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}