Let's start by creating entry for server in docker-compose.yaml
:
version: '2'
# version 2 of docker-compose is not "old" version, it's the actual version,
# see below for explanation:
# https://stackoverflow.com/a/53636006/961092
services:
# Percona Monitoring and Management server
pmm-data:
image: percona/pmm-client:2
container_name: pmm-data
hostname: pmm-data
volumes:
- /srv
entrypoint: /bin/true
pmm-server:
image: percona/pmm-server:2
hostname: pmm-server
container_name: pmm-server
restart: always
# logging settings limit used disk space
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
ports:
- "443:443"
# uncomment expose section in order to proxy requests through another container instead of
# accessing the container directly
# expose:
# - "443"
volumes_from:
- pmm-data
After that, you could do docker compose up -d pmm-server
and access it on https://127.0.0.1/graph/ with login credentials admin:admin
Change the password and create new user reporter
with Admin rights to use it for client setup on the next step.
No instructions for docker installation of client v2 are available at the moment, so deb install guide was used as a starting point for that guide.
First, create file pmm-agent.yaml
with mode 0666
so container user will be able to write to it: touch pmm-agent.yaml && chmod 0666 pmm-agent.yaml
Then make sure your docker-compose.yaml
has the following content:
version: '2'
services:
# Percona Monitoring and Management client
pmm-client:
image: percona/pmm-client:2
# select unique hostname, as it will be used for reporting
hostname: pmm-client-my-cool-mysql-for-blog
container_name: pmm-client
# depends_on section is needed if you're monitoring DB that is running in the docker-compose
depends_on:
- mysql-server
# pmm-agent.yaml will contain credentials and should not be added to git or shared with anyone
volumes:
- ./pmm-agent.yaml:/etc/pmm-agent.yaml
# uncomment the ports section in case your pmm-server is on another host,
# to see full list of ports you need to expose please see `docker-compose logs pmm-client`
# after start of the container for lines like that:
# > Sending status: RUNNING (port 42000). <...>
# > Sending status: RUNNING (port 42001). <...>
# ports:
# - "42000:42000"
# - "42001:42001"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
restart: always
environment:
- PMM_AGENT_CONFIG_FILE=/etc/pmm-agent.yaml
Before starting the container we need to generate a configuration for it by connecting to the server for the first time. For that temporary add entrypoint
section with the following text in it, replacing pass
with the password of the reporter
user you created on the previous step.
# important, if pmm-server is on different host you have to access it directly,
# accessing it trough proxy like nginx wouldn't work
entrypoint: pmm-agent setup --server-insecure-tls --server-address=pmm-server:443 --server-username=reporter --server-password='pass'
After that run docker-compose up pmm-client
once, check that output doesn't contain errors, and then erase the entrypoint
section you just added. Expected output:
Registering pmm-agent on PMM Server...
Registered.
Configuration file /etc/pmm-agent.yaml updated.
Please start pmm-agent: `pmm-agent --config-file=/etc/pmm-agent.yaml`.
Here the initial setup is done, docker-compose up -d pmm-client
will start the client with the new settings and it should start reporting itself in the PMM Server interface. It won't send any DB data yet, for that to work you need to set up each DB you want to monitor from this machine (with that client) once.
Sidenote, in case you are running pmm-client on another host than pmm-server, after the configuration file is created to make it work via external IP run docker exec pmm-client /usr/local/percona/pmm2/bin/pmm-admin config external_ip container pmm-client-my-cool-mysql-for-blog
with pmm-client name different than one used above to make server use IP you provide instead of an internal one, and remove the old instance from pmm-server GUI afterwards.
First, we need to prepare the DB. Requirements section in the official documentation has the details, here is what you need to do:
- for MySQL 5.7+ of any flavour (including MariaDB) you need to set innodb_monitor_enable to
all
- only for MariaDB (10.0+) you need to set performance_schema to
on
The second step is creating a MySQL user. For that in the MySQL run following, replacing pass
with randomly generated password (for example by running docker exec -it mysql-server mysql -u root -p
):
-- @'%' and not @'localhost' because in docker client would be connecting not from the localhost
-- if you want, use '172.17.0.0/255.255.0.0' (172.17.0.0/16) to restrict logging to the docker network
-- if you don't use docker, just stick to 'localhost'
CREATE USER 'pmm'@'%' IDENTIFIED BY 'pass' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'%';
FLUSH PRIVILEGES;
The last step is to register the DB from the client on the server: execute docker exec -it pmm-client /bin/bash
to get a shell in the client container, and then run the following command inside:
pmm-admin add mysql --username=pmm --password 'pass' --host mysql-server --query-source=perfschema
# in case you're monitoring local DB and want to connect by socket, use that instead:
# pmm-admin add mysql --username=pmm --password 'pass' --socket=/var/path/to/mysql/socket --query-source=perfschema
This work is distributed by CC-BY-4.0 license, feel free to alter it in a fork and ping me to update it with your changes.
Deb/rpm instructions now on this page: https://www.percona.com/doc/percona-monitoring-and-management/2.x/setting-up/client/index.html
MySQL client config page is now https://www.percona.com/doc/percona-monitoring-and-management/2.x/setting-up/client/mysql.html
pmm-client Docker is now at https://hub.docker.com/repository/docker/percona/pmm-client (not perconalab)