Signing up for MMS and setting up the MMS monitoring agent

MMS is a cloud-based or on-premises service that enables you to monitor your MongoDB cluster. The on-premise version is available with the 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 be using for the purpose of monitoring. Refer to the Single node installation of MongoDB recipe in Chapter 1, Installing and Starting the MongoDB Server, to start a MongoDB instance and connect to it from a Mongo shell. The monitoring agent, used to send the statistics of the Mongo instance to the monitoring service, uses Python and PyMongo. Refer to the Installing PyMongo recipe in Chapter 3, Programming Language Drivers, to know more about how to install Python and PyMongo, the Python client of MongoDB.

How to do it…

  1. If you don't already have an MMS account, then log in at https://mms.mongodb.com/ and sign up for an account. On signing up and logging in, we should see the following page:
    How to do it…
  2. Click on the Get Started button under Monitoring.
  3. 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 API key too. For example, if the Windows platform is selected, we would see the following page:
    How to do it…
  4. Once the installation is complete, open the monitoring-agent.config file, which will be present in the configuration folder selected while installing the agent.
  5. Look out for the mmsApiKey key in the file and set its value to the API key that was noted down earlier in step 3.
  6. To start a service manually, we have to go to services.msc on MS Windows, which can be done by typing services.msc in the Run dialog (Windows + R). The service will 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 the success message will be shown.
  7. 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/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); 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…
  8. Once the host details are added, click on the Verify Host button. Once the verification is done, click on the Start Monitoring button.

We have successfully set up MMS and added one host to it, which would be monitored.

How it works…

In this recipe, we have set up the 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 ok.

Suppose we have a replica set up and running (refer to the Starting multiple instances as part of a replica set recipe in Chapter 1, Installing and Starting the MongoDB Server, for more details on how to start a replica set), and the three members are listening to ports 27000, 27001, and 27002, respectively. Refer to step 7 in the How to do it… section, where we set up one standalone host. If we select Replica Set in the dropdown for Host Type, and for the internal hostname we 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 automatically be discovered and they will be visible under the hosts, as shown in the following screenshot:

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. If authentication is enabled, we need proper credentials for the MMS agent to gather the statistics. The DB username and password that we give while adding a new host (step 7 of the How to do it… section) should have a minimum of clusterAdmin and readAnyDatabase roles.

There's more…

What we saw in this recipe was setting up an MMS agent and creating an account from the MMS console. However, we can add groups and users for the MMS console as administrators, 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