Mongo Monitoring Service(MMS) is a service that ensures that the MongoDB is up and running and can alert us when the service is stopped/restarted.It can be run on an on-premise architecture or in the cloud like AWS.
We have multiple servers running MongoDB service and they are present in different environments as Production, Staging and Development. We needed a service that can be used to trigger an alert when a service MongoDB goes down. MMS can be configured to alert if the monitored MongoDB process is down.
MMS as a solution
We will install a monitoring agent on our MongoDB instance. The agent will keep sending pings to MMS Servers that ensures that the host is reachable and service is running. There are three types of agents that are available in Mongo Monitoring Service:
1) Automation agent
Automation agent manages the Monitoring and Backup agents and their start, restart, and upgrades as per need.
Automation agent allows only one agent of each type per machine and it will remove any additional agents. It will remove a Backup agent from a machine that have more than one Backup Agents.
2) Monitoring agent
Monitoring agent (lightweight) runs within our infrastructure and collects statistics from the instances in the MongoDB deployment. The agent sends database statistics back to Cloud Manager to provide real-time reporting. We can set alerts on these indicators as per our requirement.
3) Backup agent
Backup agent(lightweight) runs within our infrastructure and backs up data from the MongoDB processes that we have specified.
Below mentioned commands are for Ubuntu servers (they will be different in different operating systems).
The steps of installation will be shown, once we create an account in MMS.
curl -OL https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_18.104.22.1681-1_amd64.deb sudo dpkg -i mongodb-mms-automation-agent-manager_22.214.171.1241-1_amd64.deb sudo vim /etc/mongodb-mms/automation-agent.config mmsGroupId= ************* mmsApiKey= **************************** sudo mkdir /data sudo chown mongodb:mongodb /data</div> sudo start mongodb-mms-automation-agent
*The mmsGroupId & mmsApiKey is unique for each account.
*We should have a directory to store MongoDB data. This directory must be owned by the MongoDB User. Any directory is fine, but the default suggested by MMS is /data.
We can see reboots in MMS graphs expressed as red vertical lines.There is a buffer time integrated with MMS alerts to prevent false alarms due to network hiccups. The monitoring Agent Down alert fires after 7 minutes of delay because, after the election, a new Monitoring Agent can take up to 5 minutes to send its first ping to the MMS’s end. This is the same reason why a host down alert also has a built-in delay of 9 minutes. MMS does not have faster host or agent down alerts than that. MMS do alert immediately on metrics or informational alerts (such as Primary Elected), as there’s no impact from network or processing delays.
The delays are necessary as MMS believes that it can only get a ping from our hosts once every other minute and networking or processing delays can increase this time in unpredictable ways.
We can create alerts as per our need. The alerts can be of Host is down, agent is down and it even provides a alert that can be triggered if a MongoDB is exposed to the internet.
The steps for creating alerts are as follows:
1) Under the “Alerts” tab, select “Alert Settings”.
The same is shown in the below figure.
2) Click on “Add alert” to add a new alert.
We can also select from a number of already existing alerts. The existing alerts can be edited, enabled/disabled, cloned and their history can also be seen.
Disadvantages of using MMS
Mongo Monitoring Service does network-based monitoring of MongoDB deployments. It is not possible for a network monitor to know whether a particular process is running, rather it can only test whether a host gives expected outputs on a certain port. If we want something to check whether a particular service or process is running, tools other than MMS would be a better fit.
*We can integrate Pagerduty with Mongo Management Service alerts for prompt alert and notification.