To monitor MongoDB with Database Visibility, you must be running version 2.2 or newer. 

If you are configuring a collector for a MongoDB cluster, you only need to configure one collector for the entire cluster. You can choose any node in the cluster to connect to, and the entire cluster will automatically be detected.

Connection Details

FieldDescription
Database TypeThe database type that you want to monitor.
Database AgentThe Database Agent that manages the collector.
NameThe name you want to identify the collector by.
Hostname or IP AddressThe hostname or IP address of the machine that your database is running on.
Listener PortThe TCP/IP address of the port on which your database communicates with the Database Agent
Custom Connection StringThe connection string generated by the database agent. You can also specify a custom connection string, which is useful for setting custom authentication options.
UsernameThe name of the user who is connecting to and monitoring the database through the Database Agent. The user should have the permissions described in User Permissions for MongoDB.
PasswordThe password of the user who is connecting to and monitoring the database through the Database Agent.
CyberArkClick to enable CyberArk for database username and password. When CyberArk is enabled, information about Application, Safe, Folder, and Object is required to fetch the username and password for your database. To use CyberArk with Database Visibility, you must download the JavaPasswordSDK.jar file from the CyberArk web site and rename the file to cyberark-sdk-9.5.jar. Then, you must copy the JAR file to the lib directory of the database agent zip file. 
Exclude DatabasesThe databases that you want to exclude, separated by commas.
Logging EnabledClick to enable verbose mode logging, which logs all communications between the Controller and the Collector. Enable only during troubleshooting because logging consumes a lot of disk space. If you have enabled logging, you can click the logging icon in the Log column of the Collector Administration window to view the log file. The log files are located in the <db_agent_home>\agent directory and have the format <CollectorName>_out.log and <CollectorName>_err.log.

User Permissions for MongoDB

For MongoDB versions prior to 2.6.X, the readAnyDatabase and ClusterMonitor built-in roles are required in order to monitor using AppDynamics Database Visibility. For MongoDB sharded clusters, the monitoring user must have access to all shards.

For MongoDB 2.6 and later, the new clusterMonitor built-in role in addition to readAnyDatabase is required.

If you choose to create a new user to monitor MongoDB, the user must be created in the admin database.

You can configure user roles as shown in the sample query below:

use admin
db.createUser({ user: "tanujaAdmin",
pwd: "tanuja123",
    roles: [ 
	{ role: "clusterMonitor", db: "admin" },
  	{ role: "readAnyDatabase", db: "admin" },
    ] 
})
CODE