MongoDB is an open source, NoSQL, document-oriented database system. For more information visit mongodb.org.
Even if the MongoDB plugin is not configured, Monitoring will discover MongoDB services running in your Cloud Platform project by:
- searching instance names for mongodb
- checking for ports opened to 27017, 27018, or 27019 via firewall rules
The services discovered are displayed on the MongoDB Services page in the Resources menu. After you install the monitoring agent and the MongoDB plugin on your instances, Monitoring populates the MongoDB Services page with inventory and metrics.
Configuring Monitoring to monitor MongoDB
After you install the monitoring agent, use the following instructions to configure the MongoDB plugin on your instances.
For a MongoDB database with access roles (configured to run in "auth" mode) you
must configure a user with the clusterMonitor role on the admin database.
This user and password are referred to as
STATS_PASS in the following config file.
In "noauth" mode, any program that is able to connect to the MongoDB server can run arbitrary queries and commands on it. Therefore, "noauth" mode is generally considered less safe. When your database runs in "noauth" mode, you don't need any credentials in the plugin configuration file.
Enabling the MongoDB monitoring plugin
If you want to monitor a cluster of multiple MongoDB servers (one primary and one or more secondaries), the monitoring agent should be installed on each node in the cluster.
(cd /opt/stackdriver/collectd/etc/collectd.d/ && curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/mongodb.conf)
When running MongoDB in "auth" mode, you will need to edit the downloaded
configuration file and replace
STATS_PASS with the above
username and password, respectively.
After adding the configuration file, restart the monitoring agent by running the following command:
sudo service stackdriver-agent restart
Information on other plugin configuration options can be found at collectd.org.
What is monitored
The MongoDB plugin monitors the following metrics:
- Current Connections (count): The number of active connections to MongoDB.
- Global Lock Hold Time (ms): How long the global lock has been held.
- Mapped Memory (bytes): The amount of mapped memory used by MongoDB. This is roughly equivalent to the total size of your database, due to the use of memory mapped files.
- Virtual Memory (bytes): The amount of virtual memory used by MongoDB. If the virtual memory size is significantly larger than mapped memory size (e.g. 3 or more times), this may indicate a memory leak.
- Resident Memory (bytes): The amount of resident memory that is used by MongoDB. This is the amount of RAM being physically used by the database.
- Operations [command, delete, getmore, insert, query, update] (count/s): The number of [command, delete, getmore, insert, query, update] operations executed per second.
- Database [Collection, Index, Object, Extents] Count (count): The number of [collections, indices, objects, extents] currently in the database.
- Database Data Size (bytes): The size of the data currently in the database.
- Database Storage Size (bytes): The size of the storage currently allocated to the database.
- Database Index Size (bytes): The size of the index for the database.