Signing up for MMS and setting up an MMS monitoring agent

MMS is a cloud-based or on-premise service that enables you to monitor your MongoDB cluster. The on-premise version is available with an enterprise subscription only. It gives you one central place that lets the administrators monitor the health of the server instances and the boxes on which the instances are running. In this recipe, we will see what the software requirements are and how to set up MMS for Mongo.

Getting ready

We will be starting a single instance of mongod, which we will use for monitoring purposes. Refer to the recipe Installing single node MongoDB from Chapter 1, Installing and Starting the Server to start a MongoDB instance and connect to it from a Mongo shell. The monitoring agent used for sending the statistics of the mongo instance to the monitoring service uses Python and pymongo. Refer to the recipe Connecting to a single node using a Python client in Chapter 1, Installing and Starting the Server to learn more about how to install Python and pymongo, the Python client of MongoDB.

How to do it…

If you don't already have a MMS account, then log in to https://mms.mongodb.com/ and sign up for an account. On signing up and logging in, you should see the following page:

How to do it…

Click on the Get Started button under Monitoring.

  1. Once we reach the Download Agent option in the menu, click on the appropriate OS platform to download the agent. Follow the instructions given after selecting the appropriate OS platform. Note down the apiKey too. For example, if the Windows platform is selected, we would see the following:
    How to do it…
  2. Once the installation is complete, open the file monitoring-agent.config. It will be present in the configuration folder selected while installing the agent.
  3. Look out for the key mmsApiKey in the file and set its value to the API key that was noted down in step 1.
  4. Once the service is started (we have to go to services.msc on Windows, which can be done by typing services.msc in the run dialog (Windows + R) and start the service manually). The service would be named MMS Monitoring Agent. On the web page, click on the Verify Agent button. If all goes well, the started agent will be verified and a success message will be shown.
  5. The next step is to configure the host. This host is the one that is seen from the agent's perspective running on the organization or individual's infrastructure. The following screen shows the screen used for the addition of a host. The hostname is the internal hostname (the hostname on the client's network), and the MMS on the cloud doesn't need to reach out to the MongoDB processes. It is the agent that collects the data from these mongodb processes and sends the data to the MMS service.
    How to do it…

    Once the host's details are added, click on the Verify Host button. Once verification is done, click the Start Monitoring button.

    We have successfully set up MMS and added one host to it that will be monitored.

How it works…

In this recipe, we set up an MMS agent and monitoring for a standalone MongoDB instance. The installation and setup process is pretty simple. We also added a standalone instance and all was okay.

Suppose we have a replica set up and running (refer to the recipe Starting multiple instances as part of a replica set in Chapter 1, Installing and Starting the Server, for more details on how to start a replica set) and the three members are listening to ports 27000, 27001, and 27002. Refer to point number 6 in the How to do it… section where we set up one standalone host. In the drop-down menu for Host Type select Replica Set and in the Internal hostname, give a valid hostname of any member of the replica set (in my case Amol-PC and port 27001 were given, which is a secondary instance); all other instances will be automatically discovered and will be visible under the hosts, as shown here:

How it works…

We didn't see what is to be done when security is enabled on the cluster, which is pretty common in production environments and we have replica sets or shard setup. If authentication is enabled, we need proper credentials for the MMS agent to gather the statistics. The DB Username and DB Password that we give while adding a new host (point number 6 in the How to do it… section) should have a minimum of clusterAdmin and readAnyDatabase role.

There's more…

What we saw in this recipe was how to set up MMS agent and create an account from the MMS console. However, we can add groups and users for the MMS console as an administrator granting various users privileges for performing various operations on different groups. In the next recipe, we will throw some light on user and group management in the MMS console.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset