MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.

MongoDB can run over multiple servers, balancing the load or duplicating data to keep the system up and running in case of hardware failure.

For monitoring MongoDB, In Linux/Unix, a Java-based agent is used. In Windows, you can use a .net-based agent (preferred) or a Java-based agent. The agent runs the queries periodically to collect metrics/detailed DB information. Mongo DB monitors covers a wide range of metrics comprising the following:

- Time Series Metric Monitoring (TSMM) - TSMM collects metrics that can be used to visualize the performance of your MongoDB on our dashboard. An extensive coverage that includes multiple data points from the following categories:
  - MongoDB Collection stats
  - MongoDB Database stats
  - MongoDB Replica stats
- MongoDB Server statsDetailed DB Monitoring (DDBM) - DDBM gives you deeper insight into the performance of your MongoDB by capturing currently running queries, sessions, locks, and DB IO Stats. The metrics that are to be captured can be checked from this configuration page and the detailed DB Monitoring module can be accessed by clicking on Configurations → DB Monitoring. An extensive coverage that includes multiple data points from the following category:
  - Mongo DB Session Summary
  - Mongo DB Execution Plan

Note: You can see the monitor information for specific monitors by clicking on the Information icon provided alongside the monitor type.

## Platform Supported

MongoDB Monitoring is supported for the following operating systems:

- Linux Server -- Ubuntu 16 onwards, RHEL version 7 & above
- Windows Server -- 2012 onwards

## Pre-Requisites

- You will need to create a monitor plug-in that will monitor MongoDB. Our machine agent will make a connection to the MongoDB database.
- After making a connection with the database, the monitor will execute MongoDB API function calls that will provide the health status of the MongoDB server.
- Below keywords need to be added in “mongod.conf” to enable queries profiling:

operationProfiling:
mode: all
slowOpThresholdMs: 0
slowOpSampleRate: 1

- You will either need credentials for an existing read-only user or create a new read-only user via the following steps:

db.createUser({

"user": "cavisson",

"pwd": "<UNIQUEPASSWORD>",

"roles": [

{ role: "read", db: "admin" },

{ role: "clusterMonitor", db: "admin" },

{ role: "read", db: "local" }

]

})

Note: Pre-requisites are the same for Host and Kubernetes.

## Monitor Group Configuration

### Mongo DB Configuration

To successfully configure MongoDB monitoring, you are required to fill in the following fields:

- Host Name/IP: Provide the hostname/IP of the machine on which the mongo db database resides. The default value for Host IP is 0.0.1. It is a mandatory field.
- Port: The port on which the connection will be made along with the hostname/IP. The default value is 27017. It is a mandatory field.
- Username/Password: In this field, the user has to provide the username and password where the Mongo DB is set up. It is a mandatory field.
- Authentication Database: In this field, the user has to provide the authentication database for the user. The default value is admin. It is an optional field.
- SSL Settings: In this field, the user has to provide the pem file path (It is the path on which the pem file is being located) for Mongo DB.

## Common Configuration

All metrics in monitors have the following common fields which are optional:

- Frequency: Each sample will come in a selected frequency in the graph. It can be 10 secs, 10 minutes, 1 hour, 4 hours, or 1 day.
- Other Arguments: It is for enabling debug mode or passing any extra argument JSON.

## Monitor Group-Specific Configuration

The following monitor groups have additional configuration fields, described below:

- MongoDB Collection Stats: MongoDB Collection Stats monitor provides storage statistics for the collections.
  - Connect to: It has the following fields:
    - All DB: If the user selects this option from the drop-down, then it will provide the storage statistics for all the connected dBs'.
    - Specific DB: If the user selects this option from the drop-down, then it will provide the storage statistics for specific dBs' which are selected by the user.

Note: In case a user selects Specific DB option, the user also has to provide the name of the DB which they want to use in the DB Name field.

- MongoDB Database Stats: MongoDB Database Stats provides storage statistics for a given database.
  - Connect to: It has the following fields:
    - All DB: If the user selects this option from the drop-down, then it will provide the storage statistics for all the connected dBs’.
    - Specific DB: If the user selects this option from the drop-down, then it will provide the storage statistics for the given database.

Note: In case a user selects Specific DB option, the user also has to provide the name of the DB which they want to use in the DB Name field.

- Mongo DB Session Summary: MongoDB session summary provides storage statistics for a given session.
  - Session: It has the following option:
    - Active: Shows the session which is active.
    - Active & Idle: Shows the active and idle sessions.
  - Mongo DB Execution Stats: MongoDB execution stats provide statistics for a given execution.
  - Connect to: It has the following fields:
    - All DB: If the user selects this option from the drop-down, then it will provide the storage statistics for all the connected dBs’.
    - Specific DB: If the user selects this option from the drop-down, then it will provide the storage statistics for the given database.

Note:

1. In case a user selects the Specific DB option, the user also has to provide the name of the DB which they want to use in the DB Name
2. The above metric configurations are the same for both the Host and Kubernetes configurations.

## Deploy Monitors

Deploy the configured monitors using our machine agent. The following fields need to be filled in to deploy:

- Tier: Tier is used to select the tier on which the monitor(s) will be deployed. Select the required tier from the drop-down list.
- Server: You can select the server(s) of the selected tier on which the configured monitor(s) will get deployed.

Based on the requirement, you can select any one of the following:

- All: Deploy the configured monitors on all the servers of the selected tier.
- Any: Select any one of the servers where monitors will be deployed.
- Specified Server: Select one or multiple servers of the chosen tier on which the monitor(s) will be deployed. It means that with monitors whether we require all servers, any server, or a specified server.
- Exclude Server: In this field, you have to select one or more servers that you want to exclude.
- Exclude Tier: In this field, you have to select one or more tiers that you want to exclude.

Notes:

- If you want to add more tiers and servers, then you can click on the Add Agent Tier-Server
- Once you have selected all the fields, you have to click on the Add Add button to add the tier and server.
- On clicking the add button, the tier server will be added in the table.
- You can perform the following actions in the table which are listed below:
  1. Edit: In edit option, you can edit the configuration. To perform this operation, you have to click on the Edit Monitor Configuration Once you have edited the configuration, you have to click on the Update Update button to update the table. You can also click on the
     Cancel Cancel button if you don’t want to edit the window.
  2. Delete: In delete, you can delete the configuration. To perform this operation, you have to click on the Delete button
  3. Test Monitor:
     - In test monitor, you have to select tier, server, frequency, and duration from the dialog box and then click on the Test Monitor Once you click on the test button, the test will start and the Open Dashboard Open Dashboard button will be enabled and the monitor log will be displayed.
     - Once you click on the open dashboard button, a new dashboard will open in a separate tab where you can see the data.

## Validation

Once the Mongo DB monitor is validated after completing the above fields, it automatically comes on the monitoring homepage with the number of monitors running, failed, or disabled details.