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. Refer the following prerequisites for configuring MongoDB agent for both remote and local monitoring.

Before you begin

  • Review the hardware and software prerequisites. For the up-to-date system requirement information, see the the Software Product Compatibility Reports (SPCR) for the MongoDB agent.
  • Ensure that the user, who configures the MongoDB agent, has the required roles to collect data for all attributes.
    • To configure the agent on the MongoDB database version 2.4 and version 2.6, the clusterAdmin, readAnyDatabase, and dbAdminAnyDatabase roles must be assigned to the user
    • To configure the agent on the MongoDB database version 3.x and 4.x, the clusterMonitor, readAnyDatabase, and dbAdminAnyDatabase roles must be assigned to the user
    To know about the attribute groups for which these user roles are required, see Table 1.
  • Use an existing user or create a user in the admin database.
    Important: Before you create a user and grant the required roles to the user, you must 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.

The following table contains information about the user roles and the attributes for which these user roles are required:
Table 1. Attributes groups and their required user roles
Roles MongoDB database version Attribute groups
dbAdminAnyDatabase 2.x, 3.x and 4.x Response Times
readAnyDatabase 2.x, 3.x and 4.x
  • Mongod Listing
  • General Shard Information
  • Collection Storage
  • Database Names
  • Shard Details
  • Collection Storage Details
clusterAdmin 2.x, 3.x and 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 and 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
    1. Since MongoDB agent requires mongo shell to collect information remotely from the MongoDB server, the system on whichMongoDB 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.
    2. 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.

The product version and the agent version often differ. The directions here are for the most current release of this agent. For information about how to check the version of an agent in your environment, see Agent version command. For detailed information about the agent version list and what's new for each version, see the Change history.

Remember:
  • For the agent to successfully collect data, start the agent with the super (root) user, or use the same user ID to start the agent and the mongod process.
  • In an environment where MongoDB runs as a cluster, ensure that you install the agent on the same computer where the router process is running. Configure the agent on the same computer with the IP address and port number of that computer and the setup TYPE as 1.
  • In an environment where MongoDB runs as a cluster in authentication mode, ensure that you add the same user ID with the required rights on all the shards in the cluster.

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