While Mongo’s log files have a plethora of useful information and statistics, some information can not be captured on a per-operation basis—metadata that captures the high-level health or behavior of a MongoDB instance. This data includes overall active lock count, queue length, master status, and system-level stats.
To that end, we have written an example script that can be run via cron, in order to actively poll a specific MongoDB instance and collect these statistics at regular intervals for collection by Honeycomb.
The script can be found on GitHub in our
mongodbtools repository and is highly recommended for monitoring production MongoDB clusters.
It is customizable for your specific cluster and concerns.
Our script simply uses the
mongo shell to capture and format the output of useful commands.
wget -q https://raw.githubusercontent.com/honeycombio/mongodbtools/master/scripts/mongo_stats.sh chmod 755 mongo_stats.sh ./mongo_stats.sh YOUR_API_KEY MongoDB locahost:27017
Note: While the field names collected by this script differ from those collected by the logs parser, we highly recommend using the same dataset name here. Interleaving these two different types of events will provide a richer and more interesting set of analyses over your MongoDB cluster.
Note: MongoDB statistics and shell methods (and the information returned by the above) vary between different MongoDB versions. The fields extracted from your MongoDB log output may differ from those shown above, and we recommend customizing the provided example script to match your MongoDB version and specific needs.
Numbers are ingested as floats by default in Honeycomb, though you can coerce a field to integers in the Schema section of your dataset’s Overview.
Did you find what you were looking for?