How to Monitor MySQL with Percona Monitoring and Management on RHEL 7
Percona Monitoring and Management (PMM) is a free, open-source platform for monitoring MySQL, MariaDB, PostgreSQL, and MongoDB. It combines Grafana dashboards, Prometheus metrics collection, and Query Analytics (QAN) into a single integrated UI. Unlike generic monitoring tools, PMM understands database internals and surfaces query-level performance data alongside system metrics. This tutorial covers deploying the PMM Server as a Docker container and connecting a RHEL 7 MySQL host using the pmm-client package.
Prerequisites
- RHEL 7 server running MySQL 5.6 or 5.7 (the monitored host)
- A separate host or VM for PMM Server (can be the same host for testing)
- Docker installed on the PMM Server host
- Network connectivity between PMM Client host and PMM Server on TCP 443 or 80
- Root or sudo access on both hosts
- EPEL repository enabled on the client host
Step 1: Deploy PMM Server via Docker
PMM Server ships as a Docker image. On the server host, install Docker and pull the PMM image. If Docker is not already installed:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker
sudo systemctl start docker
Create a persistent data volume container, then launch PMM Server:
docker create
-v /srv
--name pmm-data
percona/pmm-server:2 /bin/true
docker run -d
-p 443:443
-p 80:80
--volumes-from pmm-data
--name pmm-server
--restart always
percona/pmm-server:2
After a minute or two, browse to https://<pmm-server-ip>. Accept the self-signed certificate and log in with username admin and password admin. You will be prompted to change the password on first login.
Step 2: Install pmm-client on the Monitored Host
On the RHEL 7 MySQL host, add the Percona YUM repository and install pmm2-client:
sudo yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
sudo percona-release setup pmm2-client
sudo yum install -y pmm2-client
Verify the installation:
pmm-admin --version
Step 3: Register the Client with PMM Server
Use pmm-admin config to point the client at your PMM Server. Replace the IP address and credentials as appropriate. The --server-insecure-tls flag is needed when using the default self-signed certificate.
sudo pmm-admin config
--server-insecure-tls
--server-url=https://admin:[email protected]
A successful registration returns:
Checking local pmm-agent status...
pmm-agent is running.
Registering pmm-agent on PMM Server...
Registered.
Configuration file path: /usr/local/percona/pmm2/config/pmm-agent.yaml
Enable and start the PMM agent service so it survives reboots:
sudo systemctl enable pmm-agent
sudo systemctl start pmm-agent
Step 4: Create a PMM MySQL User
PMM needs a dedicated MySQL user with specific privileges to collect metrics and query data. Log in to MySQL as root and create this user:
mysql -u root -p
CREATE USER 'pmm'@'localhost' IDENTIFIED BY 'pmm_strong_password' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'localhost';
GRANT SELECT, UPDATE, DELETE, DROP ON performance_schema.* TO 'pmm'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Add MySQL to PMM Monitoring
With the PMM user in place, register the MySQL instance with the agent. The pmm-admin add mysql command configures both metrics collection and Query Analytics.
sudo pmm-admin add mysql
--username=pmm
--password=pmm_strong_password
--host=127.0.0.1
--port=3306
--service-name=mysql-prod-01
--query-source=perfschema
The --query-source=perfschema flag uses the MySQL Performance Schema for query capture. Alternatively, use slowlog to rely on the MySQL slow query log:
sudo pmm-admin add mysql
--username=pmm
--password=pmm_strong_password
--service-name=mysql-prod-01
--query-source=slowlog
For the slow query log to work, enable it in MySQL:
mysql -u root -p -e "SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 0;
SET GLOBAL log_output = 'FILE';"
Step 6: Verify Network Connectivity
Use pmm-admin check-network to confirm the agent can reach all PMM Server endpoints:
sudo pmm-admin check-network
The output shows connectivity status for each required port. All lines should show OK. If any show failures, check firewall rules on both the server and client:
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
Step 7: List Monitored Services
Confirm the MySQL service is registered and sending data:
sudo pmm-admin list
Output should list the MySQL service with a Running status:
Service type Service name Address and port Service ID
MySQL mysql-prod-01 127.0.0.1:3306 /service_id/...
Step 8: Explore Grafana Dashboards
Log in to the PMM UI at https://<pmm-server-ip>, then navigate to the Grafana dashboards via the grid icon. PMM ships with pre-built dashboards including:
- MySQL Overview — queries per second, connections, buffer pool hit rate
- MySQL InnoDB Metrics — row operations, lock waits, file I/O
- MySQL Replication — replica lag, running replicas
- Node Summary — CPU, RAM, disk I/O, network for the OS layer
All dashboards update in real time. Use the time picker in the top right to zoom into specific intervals during incidents.
Step 9: Query Analytics (QAN)
Click the Query Analytics menu item to open QAN. This view ranks queries by total load (query time × frequency) and shows explain plans, example queries, and per-query latency histograms. To drill into a slow query:
- Select a time range covering the period of interest using the time picker.
- Sort the query list by Load descending.
- Click a query row to expand the detail panel.
- Review the Explain tab to identify missing indexes or full table scans.
Step 10: Configure Grafana Alerts
PMM exposes Alertmanager and supports Grafana-native alerting. To create a simple alert for high connection count, navigate to any MySQL dashboard panel, click the panel title, select Edit, then choose the Alert tab. Set a threshold, define a notification channel (email, Slack, PagerDuty), and save. PMM also ships with pre-built alert rules in the Alerting section under PMM > Backup & Alerting for common DBA concerns like replication lag exceeding 60 seconds or InnoDB deadlocks per minute.
Percona Monitoring and Management transforms raw MySQL metrics into actionable performance intelligence. The combination of infrastructure-level Prometheus metrics, Grafana visualisation, and SQL-level Query Analytics gives your team everything needed to diagnose slowdowns before they impact users. As your environment grows, PMM scales horizontally by adding more client nodes — each additional pmm-admin add mysql registration appears automatically in the PMM Server UI without any manual dashboard configuration.