Skip to content

A utility for rolling up MongoDB collection statistics to the database level

Notifications You must be signed in to change notification settings

misczak/mongo_db_stats

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Database Statistics

MongoDB provides detailed statistics at the collection level via its collStats and top commands. The Compass Performance tab will even show you the Hottest Collections:

Hottest Collections

However, since it is not uncommon to have multiple application teams sharing a MongoDB cluster, it is often desirable to see this type of information rolled up to the database level.

The analyze-db.py script uses information from collStats and top to roll up information on db cache use and a list of hottest dbs:

$ python3 analyze-db.py

MongoDB Database Stats

Analyzing Database Cache Use...

 Database                  Cache Used (MB)
 --------                  ---------------
 local                       1238.762
 demos                        109.216
 sample_airbnb                 97.617
 sample_mflix                  39.312
 sample_training               26.328
 sample_weatherdata            11.996
 --------                  ---------------
 Total                       1523.747

Calculating Hottest DBs...

 Database                         CPU   CPU Read  CPU Write
 --------                   ---------  ---------  ---------
 demos                          6.11%      5.77%      0.34%
 local                          0.41%      0.41%       0.0%
 sample_mflix                   0.26%       0.0%       0.0%
 enron                          0.14%       0.0%       0.0%
 --------                   ---------  ---------  ---------
 Total                          6.92%      6.18%      0.34%

Analysis Complete

Note the script also persists its findings back to a dbstats database, which allows for historical analysis. For example, you can use MongoDB Charts to graph the results over time:

Cache Use Over Time by Database

About

A utility for rolling up MongoDB collection statistics to the database level

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 76.1%
  • JavaScript 23.9%