As a Solutions Engineer at Percona, one of my responsibilities is to support our customer-facing roles such as the sales and customer success teams, which affords me the opportunity to speak to many current and new customers who partner with Percona. I often find that many people are interested in Percona Monitoring and Management (PMM) as a free and open-source monitoring solution due to its robust monitoring capabilities when compared to many SaaS-based monitoring solutions. They are interested in installing PMM for MongoDB for the first time and want a “quick start guide” with a brief overview to get their feet wet. I have included the commands to get started for both PMM 1 and PMM 2 (PMM2 is still in beta).
Overview and Architecture
PMM is an open-source platform for out-of-the-box management and monitoring of MySQL, MongoDB, and PostgreSQL performance, on-premise and in the cloud. It is developed by Percona in collaboration with experts in the field of managed database services, support, and consulting. PMM is built off of Prometheus, a powerful open-source monitoring and alerting platform, and supports any other service that has an exporter. An exporter is an endpoint that collects data on the instance being monitored and is polled by Prometheus to collect metrics. For more information on how to use your own exporters, read the documentation here.
When deployed on-premises, the PMM platform is based on a client-server model that enables scalability. It includes the following modules:
- PMM Client– installed on every database host that you want to monitor. It collects server metrics, general system metrics, and Query Analytics data for a complete performance overview.
- PMM Server – the central part of PMM that aggregates collected data and presents it in the form of tables, dashboards, and graphs in a web interface.
PMM can also be deployed to support DBaaS instances for remoting monitoring. Instructions can be found here, under the Advanced section. The drawback of this approach is that you will not have visibility of host-level metrics (CPU, memory, and disk activity will not be captured nor displayed in PMM). There are currently 3 different deployment options:
- Running PMM Server via Docker
- Running PMM Server as a Virtual Appliance
- Running PMM Server Using AWS Marketplace
For a more detailed overview of the PMM Architecture please read the Overview of PMM Architecture.
Demonstration Environment
When deploying PMM in this example, I am making the following assumptions about the environment:
- MongoDB and the monitoring host are running on Debian based operating systems. (For information on installing as an RPM instead please read Deploying Percona Monitoring and Management.)
- MongoDB is already installed and setup. The username and password for the MongoDB user are percona:percona.
- The PMM server will be installed within a docker container on a dedicated host.
Installing PMM Server
This process will consist of two steps:
- Create the docker container – docker will automatically pull the PMM Server image from the Percona docker repository.
- Start (or run) the docker container – docker will bring up the PMM Server in the container
Create the Docker Container
The code below illustrates the command for creating the docker container for PMM 1:
docker create \ -v /opt/prometheus/data \ -v /opt/consul-data \ -v /var/lib/mysql \ -v /var/lib/grafana \ --name pmm-data \ percona/pmm-server:1 /bin/true
The code below illustrates the command for creating the docker container for PMM 2:
docker create -v /srv --name pmm-data-2-0-0-beta1 perconalab/pmm-server:2.0.0-beta1 /bin/true
This is the expected output from the code:
Use the following command to start the PMM 1 docker container:
docker run -d \ -p 80:80 \ --volumes-from pmm-data \ --name pmm-server \ --restart always \ percona/pmm-server:1
Use the following command to start the PMM 2 docker container:
docker run -d -p 80:80 -p 443:443 --volumes-from pmm-data-2-0-0-beta1 --name pmm-server-2.0.0-beta1 --restart always perconalab/pmm-server:2.0.0-beta1
This is the expected output from the code:
The PMM Server should now be installed! Yes, it IS that easy. In order to check that you can access PMM, navigate in a browser to the IP address of the monitoring host. If you are using PMM 2, the default username and password for viewing PMM is admin:admin. You should arrive at a page that looks like https://pmmdemo.percona.com.
Installing PMM Client for MongoDB
Setting up DB permissions
PMM Query Analytics for MongoDB requires the user of the mongodb_exporter to have the clusterMonitor role assigned for the admin database and the read role for the local database. If you do not have these set up already, please read Configuring MongoDB for Monitoring in PMM Query Analytics.
Download the Percona repo package
We must first enable the Percona package repository on our MongoDB instance and install the PMM Client. We can run the following commands in order to accomplish this:
$ wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb $ sudo dpkg -i percona-release_latest.generic_all.deb $ sudo apt-get update
Since PMM 2 is still not GA, you’ll need to leverage our experimental release of the Percona repository. You’ll need to download and install the official percona-release
package from Percona and use it to enable the Percona experimental component of the original repository. See percona-release official documentation for further details on this new tool. The following commands can be used for PMM 2:
$ wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb $ sudo dpkg -i percona-release_latest.generic_all.deb $ sudo percona-release disable all $ sudo percona-release enable original experimental $ sudo apt-get update
Now that we have the MongoDB database server configured with the Percona software repository, we can download the agent software with the local package manager. Enter the following command to automatically download and install the PMM Client package on the MongoDB server:
$ sudo apt-get install pmm-client
To download and install the PMM 2 Client:
$ apt-get install pmm2-client
Next, we will configure the PMM client by telling it where to find the PMM server. Execute the following command to configure the PMM client:
$ sudo pmm-admin config --server=<pmm_server_ip>:80
To configure the PMM 2 Client:
$ pmm-admin config --server-insecure-tls --server-url=https://<pmm_server_ip>:443
You should get a similar output as below if it was successful:
Now we provide the PMM Client credentials necessary for monitoring the MongoDB database. Execute the following command to start monitoring and communicating with the PMM server:
$ sudo pmm-admin add mongodb --uri mongodb://percona:percona@127.0.0.1:27017
To start monitoring and communicating with the PMM 2 Server:
$ sudo pmm-admin add mongodb --use-profiler --server-insecure-tls --username=percona --password=percona --server-url=https://<pmm_ip>:443
You should get a similar output as below if it was successful:
Great! We have successfully installed PMM for MongoDB and are ready to take a look at the dashboards.
PMM for MongoDB Dashboards Overview
Navigate to the IP address of your monitoring host. http://<pmm_server_ip>.
PMM Home Dashboard – The Home Dashboard for PMM gives an overview of your entire environment to include all the systems you have connected and configured for monitoring under PMM. It provides useful metrics such as CPU utilization, RAM availability, database connections, and uptime.
Cluster Summary – it shows the statistics for the selected MongoDB cluster such as counts of sharded and un-sharded databases, shard and chunk statistics, and various mongos statistics.
MongoDB Overview – this provides basic information about MongoDB instances such as connections, command operations, and document operations.
ReplSet – provides information about replica sets and their members such as replication operations, replication lag, and member state uptime.
WiredTiger/MMAPv1/In-Memory/RocksDB – it contains metrics that describe the performance of the selected host storage engine.
Query Analytics – this allows you to analyze database queries over periods of time. This can help you optimize database performance by ensuring queries are executed as expected and within the shortest amount of time. If you are having performance issues, this is a great place to see which queries may be the cause of your performance issues and get detailed metrics for them.
What Now?
Now that you have PMM for MongoDB up and running, I encourage you to explore in-depth more of the graphs and features. A few other MongoDB PMM blog posts which may be of interest:
- PMM for MongoDB: Basic Graphs for a Good System Overview
- PMM Query Analytics Support for MongoDB
- PMM Graphs Explained: MongoDB MMAPv1
- PMM Graphs Explained: WiredTiger and Percona Memory Engine
- PMM Graphs Explained: MongoDB with RocksDS
- MongoDB Explain – Using PMM-QAN for MongoDB Query Analytics
If you run into issues during the install process, a good place to start is Peter Zaitsev’s blog post on PMM Troubleshooting.