Configuring MongoDB monitoring

The Monitoring Agent for MongoDB requires an instance name. You must manually configure and start the agent instance. The MongoDB agent supports local as well as remote monitoring.

Before you begin

To know about the attribute groups for which these user roles are required, see Table 1. Attributes groups and their required user roles.

Important: Before you create a user and grant the required roles to the user, make sure to connect to the MongoDB database and change the database to admin database. If the mongod or mongos process is running in the authentication mode, enter the required credentials to connect to MongoDB database.

  1. Run the following command to connect to the MongoDB database:

    mongo IP:port
    

    Where,
    IP is the IP address of the mongod or mongos process. port is the port number of the mongod or mongos process.

  2. Change the database to the admin database:

    use admin
    
  3. Run one of the following commands to add a user in the MongoDB admin database and assign the required roles to the user:

    • For the MongoDB database version 2.4, run the following command:
      db.addUser({ user: username, pwd: password, roles: [ 'clusterAdmin', 'readAnyDatabase', 'dbAdminAnyDatabase' ] })
      
    • For the MongoDB database version 2.6, run the following command:
      db.createUser({user: username, pwd: password, roles: [ 'clusterAdmin', 'readAnyDatabase', 'dbAdminAnyDatabase' ] })
      
    • For the MongoDB database version 3.x and 4.x, run the following command:
      db.createUser({user: username, pwd: password, roles: [ 'clusterMonitor', 'readAnyDatabase', 'dbAdminAnyDatabase' ] })
      
  4. Run the following command to verify that the user is added to the admin database:

    db.auth(username, password)
    

    Return code 1 indicates that the user is added, whereas the return code 0 indicates that the user addition failed.

Table 1. Attributes groups and their required user roles

The following table contains information about the user roles and the attributes for which these user roles are required:

Roles MongoDB database version Attribute groups
dbAdminAnyDatabase 2.x, 3.x, 4.x Response Times
readAnyDatabase 2.x, 3.x, 4.x Mongod Listing
General Shard Information
Collection Storage
Database Names
Shard Details
Collection Storage Details
clusterAdmin 2.x, 3.x, 4.x Mongo Instance Information
Mongo Inst IO Info
MII Copy For APMUI One
MII Copy For APMUI Two
Mongo Inst DB Lock
Locks
MongoDB Locks
WiredTiger Details
MMAPv1 Details
clusterMonitor 2.x, 3.x, 4.x Mongo Instance Information
Mongo Inst IO Info
MII Copy For APMUI One
MII Copy For APMUI Two
Mongo Inst DB Lock
Locks
MongoDB Locks
WiredTiger Details
MMAPv1 Details

For remote monitoring of the MongoDB server, see the two prerequisites:

a. Since MongoDB agent requires mongo shell to collect information remotely from the MongoDB server, the system on which MongoDB agent is installed and configured must have an instance of MongoDB server. The mongo shell of the MongoDB server on the agent machine is used to connect to the remote MongoDB server for monitoring.

b. In /etc/hosts file of the system that hosts the agent, there is an entry of the remote machine.

About this task

The managed system name includes the instance name that you specify. For example, you can specify the instance name as instance_name:host_name:pc, where pc is the two character product code of your agent. The managed system name can contain up to 32 characters. The instance name can contain up to 28 characters, excluding the length of your host name. For example, if you specify Mongo2 as your instance name, your managed system name is Mongo2:hostname:KJ.

Important: If you specify a long instance name, the managed system name is truncated and the agent code is not completely displayed.

Remember:

You can configure the agent by using the default settings, by editing the silent response file, or by responding to prompts.

Child topics: