MongoDB is an open source, NoSQL, document-oriented database system. The MongoDB plugin allows you to monitor your databases running on your instances.
Discovery
Even if you don't configure the MongoDB plugin, Cloud Monitoring discovers MongoDB services running in your Google Cloud project by:
- Searching instance names for mongodb
- Checking for ports opened to 27017, 27018, or 27019 via firewall rules
These discovered services appear 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, configure the MongoDB plugin on your instances.
Prerequisites
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_USER
and STATS_PASS
in the
mongodb.conf
file.
In "noauth" mode, any program that can 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.
On your VM instance, download mongodb.conf from the GitHub configuration repository and place it in
/etc/stackdriver/collectd.d/
:cd /etc/stackdriver/collectd.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/mongodb.conf
To run MongoDB in "auth" mode, as root, edit the configuration file and replace
STATS_USER
andSTATS_PASS
with the correct username and password.Make other configuration changes, such as Port or Host, as needed.
When finished, restart the monitoring agent:
sudo service stackdriver-agent restart
For more information on the collectd
mongodb
plugin, see
Plugin:MongoDB.
What is monitored
The full list of metrics the MongoDB plugin monitors is at Agent metrics: mongodb.