mongostat to monitor mongodb

MongoDB
mongostat is a utility tool provided by mongodb natively, which is being used to monitor mongoDB database, which provides overall stats of mongodb database.

mongostat is basically used to monitor mongodb database which provides stats of database server as: number of operations ( i.e. insert/read/update/delete ) serving by mongodb server, You can view insight or overview stats , what is going on inside of mongodb engine. It gives us the following insight:

  • mongostat give us per second overview of lot of things.
  • how much query for insert, read, update , delete , getMore are serving by mongodb engine per second.
  • how much operations mongo engine serve per second i.e read, write , delete, update
  • how much connections are active on this server per second.
  • how much number of netIn and netOut no of bytes for incoming and outgoing for this server per second.
  • no of queries are in queue in read/write etc.

mongostat command overview

Standalone mongoDB server run command mongostat and find following output on console:

1
2
3
4
5
6
7
8
9
10
11
[root@mysoftkey ~]# mongostat   
insert query update delete getmore command % dirty % used flushes vsize   res qr|qw ar|aw netIn netOut conn                      time
     9  1837     73      1      30    80|0     2.5   79.9       0 4.66G 3.77G   0|0   0|0  316k  6.22m  401 2017-09-18T17:00:33+05:30
     9  1984    243     *0      26    78|0     2.5   79.9       0 4.66G 3.77G   0|0   1|0  331k  5.17m  401 2017-09-18T17:00:34+05:30
    13  2061    147     *0      20    95|0     2.5   80.0       0 4.66G 3.77G   0|0   2|0  331k  3.82m  401 2017-09-18T17:00:35+05:30
     9  2018    137     *0      25    72|0     2.5   80.0       0 4.66G 3.77G   0|0   0|0  335k  5.76m  401 2017-09-18T17:00:36+05:30
     3  1392     92      3      39    79|0     2.5   80.0       0 4.66G 3.77G   1|0   0|0  271k  8.05m  401 2017-09-18T17:00:37+05:30
     2  1280     28     *0      24    69|0     2.5   80.0       0 4.66G 3.77G   0|0   0|0  194k  4.33m  401 2017-09-18T17:00:38+05:30
     9  1827    151     *0      32    78|0     2.5   80.0       0 4.66G 3.77G   1|0   0|0  284k  6.89m  401 2017-09-18T17:00:39+05:30
     6  1958    289     *0      28    83|0     2.6   80.0       0 4.66G 3.77G   1|0   1|0  331k  4.96m  401 2017-09-18T17:00:40+05:30
     7  1895    177     *0      24    97|0     2.6   78.4       0 4.66G 3.77G   1|0   0|0  320k  5.08m  401 2017-09-18T17:00:41+05:30

sample for replica Set cluster , logged-in into mongodb server and run mongostat command on terminal and see the following output.

1
2
3
4
5
6
7
8
9
10
[root@mysoftkey ~]# mongostat
insert query update delete getmore command % dirty % used flushes vsize   res qr|qw ar|aw netIn netOut conn set repl     time
   *25   464     *5     *1      14    32|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0   65k     4m  215 rs1  SEC 18:05:25
   *46  3189    *18     *5      22    16|0     0.4   33.0       0 21.4G 20.5G   0|0   4|0  343k     8m  215 rs1  SEC 18:05:26
   *33  2350    *22     *2      21    22|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  264k     7m  215 rs1  SEC 18:05:27
   *31  1872     *6     *2      22     5|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  205k     7m  215 rs1  SEC 18:05:28
   *23   996    *14     *0      23    13|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  120k     6m  215 rs1  SEC 18:05:29
   *35  1429    *13     *2      24    34|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  166k     7m  215 rs1  SEC 18:05:30
   *30   936    *13     *2       9    28|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  102k     3m  215 rs1  SEC 18:05:31
   *19  1095     *2     *1      14    20|0     0.4   33.0       0 21.4G 20.5G   0|0   1|0  125k     4m  215 rs1  SEC 18:05:32

mongostat command parameters available

For more help you can use mongostat --help , output as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
[root@mysoftkey ~]# mongostat --help
Usage:
  mongostat <options> <polling interval in seconds>
 
Monitor basic MongoDB server statistics.
 
See http://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)
 
ssl options:
      --ssl                          connect to a mongod or mongos that has ssl enabled
      --sslCAFile=                   the .pem file containing the root certificate chain from the certificate authority
      --sslPEMKeyFile=               the .pem file containing the certificate and key
      --sslPEMKeyPassword=           the password to decrypt the sslPEMKeyFile, if necessary
      --sslCRLFile=                  the .pem file containing the certificate revocation list
      --sslAllowInvalidCertificates  bypass the validation for server certificates
      --sslAllowInvalidHostnames     bypass the validation for server name
      --sslFIPSMode                  use FIPS mode of the installed openssl library
 
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
[root@mysoftkey ~]#

Your comments are welcome to improve this post. Happy Learning :)

Please follow and like us:
RSS
Follow by Email
Facebook
LinkedIn
Google+

Leave a Reply

Your email address will not be published. Required fields are marked *