Skip to content

Insight and analysis of technology and business strategy

Mongostat - A nifty tool for Mongo DBAs

One of the main MongoDB DBA's task is to monitor the usage of MongoDB system and it's load distribution. This could be needed for proactive monitoring, troubleshooting during performance degradation, root cause analysis, or capacity planning. Mongostat is a nifty tool which comes out of the box with MongoDB which provides wealth of information in a nicely and familiar formatted way. If you have used vmstat, iostat etc on Linux; Mongostat should seem very familiar. Mongostat dishes out statistics like counts of database operations by type (e.g. insert, query, update, delete, getmore). The vsize column in Mongostat output shows the amount of virtual memory in megabytes used by the process. There are other very useful columns regarding network traffic, connections, queuing etc. Following are some of the examples of running Mongostat. [mongo@mongotest data]$ mongostat insert query update delete getmore command flushes mapped vsize res faults qr|qw ar|aw netIn netOut conn time *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:29 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:30 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:31 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:32 *0 *0 *0 *0 0 2|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 133b 10k 1 12:47:33 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:34 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:35 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:36 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:37 *0 *0 *0 *0 0 2|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 133b 10k 1 12:47:38 Following displayes just 5 rows of output. [mongo@mongotest data]$ mongostat -n 5 insert query update delete getmore command flushes mapped vsize res faults qr|qw ar|aw netIn netOut conn time *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:45 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:46 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:47 *0 *0 *0 *0 0 1|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 79b 10k 1 12:47:48 *0 *0 *0 *0 0 2|0 0 160.0M 646.0M 131.0M 0 0|0 0|0 133b 10k 1 12:47:49 In order to see full list of options: [mongo@mongotest data]$ mongostat --help Usage: mongostat <options> <polling interval in seconds> Monitor basic MongoDB server statistics. See https://docs.mongodb.org/manual/reference/program/mongostat/ for more information. general options: --help print usage --version print the tool version and exit verbosity options: -v, --verbose more detailed log output (include multiple times for more verbosity, e.g. -vvvvv) --quiet hide all log output connection options: -h, --host= mongodb host to connect to (setname/host1,host2 for replica sets) --port= server port (can also use --host hostname:port) authentication options: -u, --username= username for authentication -p, --password= password for authentication --authenticationDatabase= database that holds the user's credentials --authenticationMechanism= authentication mechanism to use stat options: --noheaders don't output column names -n, --rowcount= number of stats lines to print (0 for indefinite) --discover discover nodes and display stats for all --http use HTTP instead of raw db connection --all all optional fields --json output as JSON rather than a formatted table   Discover more about our expertise in Big Data.

Top Categories

  • There are no suggestions because the search field is empty.

Tell us how we can help!

dba-cloud-services
Upcoming-Events-banner