Search
left arrowBack
Stanislav Levchenko

Stanislav Levchenko

November 16, 2022 ・ Basics

How To Set Up MongoDB Monitoring With PMM

Prepare your environment

Before you get started setting up MongoDB to connect to PMM monitoring, you need to have a PMM Client and register it on the PMM Server. Let’s do it. You may set up the PMM Client in different ways. It can be either running in a Docker container or installed by a package manager or from sources. In this article, we will use the easiest way — we will install it from the repository using a package manager. Make sure you have curl, gnupb, wget, and sudo installed on your server. First of all, you need to add the Percona repo to your repositories list.

For Debian-based OS

a. Configure repositories:

wgethttps://repo.percona.com/apt/percona-release_latest.generic_all.debdpkg -i percona-release_latest.generic_all.deb

b. Install hpmm-client package:

apt updateapt install -y pmm2-client

c. Check if it was installed correctly:

pmm-admin --version

For RedHat-based OS

a. Configure repositories:

yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm

b. Install hpmm-client package:

yum install -y pmm2-client

c. Check if it was installed correctly:

pmm-admin --version

After you have installed the PMM Client, you should register it on your server. You need the HPMM server hostname or IP-address and credentials for your connection. You may find this information on your hostedpmm private cabinet.

To register the PMM client on the server, just type:

pmm-admin config --server-insecure-tls --server-url=https://admin:<password>@XXX.XXX.XXX.XXX:443 YYY.YYY.YYY.YYY generic mynode

where XXX.XXX.XXX.XXX — IP address or hostname of PMM server, YYY.YYY.YYY.YYY — IP address or hostname of PMM client, generic — client type and mynode — mane of client.

Configure MongoDB

After MongoDB and the PMM client are installed, you need to have a user with proper privileges. You may add a user in the Mongo session:

db.getSiblingDB("admin").createRole({    role: "explainRole",    privileges: [{        resource: {            db: "",            collection: ""            },        actions: [            "listIndexes",            "listCollections",            "dbStats",            "dbHash",            "collStats",            "find"            ]        }],    roles:[]})db.getSiblingDB("admin").createUser({   user: "pmm_mongodb",   pwd: "password",   roles: [      { role: "explainRole", db: "admin" },      { role: "clusterMonitor", db: "admin" },      { role: "read", db: "local" }   ]})

If you want to use PMM Query Analytics, you should turn on the profiling feature. To make this setting permanent, edit /etc/mongod.conf adding operationProfiling section:

operationProfiling:  mode: all  slowOpThresholdMs: 200 rateLimit: 100 # (Only available with Percona Server for MongoDB.)

Restart mongod service

systemctl restart mongod

After that, you are ready to connect your MongoDB to PMM monitoring. To do that run:


pmm-admin add mongodb \
--username=pmm_mongodb --password=password \
--query-source=profiler --cluster=mycluster

You may add –environment and -custom-label options to set tags for the service to help identify them.

After successful adding, you may find your service on the PMM Server in Configuration -> PMM Inventory -> Inventory list or check on the client using the command:

pmm-admin inventory list services --service-type=mongodb

And now you should see your MongoDB on your monitoring panel.

HostedPMM Services

Now that you have MongoDB monitoring with PMM set up, you are free to focus on other important issues with your business. HostedPMM offers hosted PMM servers for monitoring, automation, troubleshooting, and convenience for all your database needs. We provide servers for PMM to help your business. You can get your own PMM server, connect your instances, and focus on your project with HostedPMM.

Get started with HostedPMM for free and enjoy more organized, adaptable, optimized, and secure database solutions. We offer quick setup, tech support, backups, scalability, security updates, high availability, and no vendor restrictions.

If you have any questions or need assistance with HostedPMM, contact us at support@hostedpmm.com for support.

How to set up open-source DB monitoring using PMM?

  • Basics