You are here

MongoDB Monitoring

Requires Opsview Cloud or Opsview Monitor 6
Opsview Supported

Database - MongoDB Opspack

MongoDB is a cross-platform, document-oriented database program and represents its documents in a binary-encoded JSON format called BSON (Binary JSON). The lightweight binary format adds speed to the flexibility of the JSON format, along with more data types. Fields inside MongoDB documents can also be indexed.

Mongo DB allows users to be agile and follow a stable process when running the most critical applications. Here are a few other highlight features:

  • Expressive query language & secondary indexes
  • Enterprise management and integration
  • Strong consistency
  • Always-on global deployments

What You Can Monitor

Opsview Monitor contains all the important service checks to make sure your MongoDB Server is up and running. Service Checks for MongoDB include:

  • CPU information for all of your MongoDB instances
  • Memory statistics including MongoDB_config and arbiter
  • Page Faults, database size, replication state and more

Service Checks

Service Check Description
MongoDB - Asserts Number of asserts
MongoDB - Chunks Balance Checks chunks are balanced across shards
MongoDB - Collection Indexes Index size of collection
MongoDB - Collection Size Size of the collection
MongoDB - Collection State Check connectivity to the collection
MongoDB - Collection Storage Size Storage size of the collection
MongoDB - Connect Primary Primary connection check
MongoDB - Connection Number of available connections being used
MongoDB - Database Indexes Database index size
MongoDB - Database Size Storage size of the database
MongoDB - Databases Number of databases
MongoDB - Flushing Average time to perform a background flush
MongoDB - Index miss Ratio Index counters miss ratio
MongoDB - Journal Average amount of data written to the recovery log (MB) in the last 4 seconds
MongoDB - Journal Commits Number of commits performed whilst in the databases write lock
MongoDB - Last Flush Time Time taken to perform the last background flush
MongoDB - Memory Total system memory
MongoDB - Memory Mapped Amount of mapped memory
MongoDB - Opcounters Number of queries per second
MongoDB - Oplog Operation log metrics
MongoDB - Page Fault Number of page faults
MongoDB - Queries Per Second Number of queries per second
MongoDB - Queue Queue metrics
MongoDB - Rep Lag Replication lag in seconds
MongoDB - Rep Lag Percent Replication lag percent
MongoDB - Replset Quorum Status of members
MongoDB - Replset State State of replset
MongoDB - Row Count Number of rows
MongoDB - Write Data Files Average amount of data in megabytes written to the databases datafiles in the last four seconds

Setup and Configuration

Setup for using all service checks

To get all the service checks working correctly, MongoDB must be set up with a database, collection, sharding and replicaset. Any of the service checks that are not needed should be disabled.

If you are not running sharding, then Chunks Balance should be disabled.

If MongoDB is running without replSet, then Rep Lag, Rep Lag percentage, Replset Quorum and Replset State should be disabled.

If you are running a MongoDB 3.2+ system, then Journal, Journal Commits and Write Data Files should be disabled as it uses WiredTiger as its storage engine.

Create a user with appropriate role for plugin to login as with MongoDB

In order for this Opspack to work, it queries the admin database to get system-wide statistics about the database deployment.

It is recommended to set up a user in a role with permissions (at least) 'ClusterMonitor', as this role "Provides read-only access to monitoring tools for administering the whole system rather than just a single database".

For example, to create a user 'Opsview' with password 'Opsview' and role 'clusterMonitor':

db = db.getSiblingDB("admin");
db.createUser( { user:"opsview",pwd:"opsview",roles:["clusterMonitor"] } );

The Opspack can then use these credentials, which you enter into Opsview, to login and query metrics.

You are at liberty to instead allow Opsview to login as an already existing user with at least this level of role access.

Step 1: Add the host template

Add the Database - MongoDB Host Template to your Opsview Monitor host.

Add MongoDB Host

For more information, refer to Opsview Knowledge Center - Adding Host Templates to Hosts.

Step 2: Add and configure variables required for this host

Variable Description
MONGODB_CREDENTIALS Used in authenticating with MongoDB. Override the Username and Password with your credentials.
MONGODB_DATABASES Used to select the database to monitor. Set the value to your database name and override the Collection and Replicaset with your details.

Add MongoDB Variables Step 1
Add MongoDB Variables Step 2

For more information, refer to Opsview Knowledge Center - Adding Variables to Hosts.

Step 3: Apply changes and the system will now be monitored

MongoDB Service Checks