How to create pmm-client in docker container to monitor MySQL database (in seperate a container)

I was following these instructions here to setup pmm-client in a container: Set up PMM Client - Percona Monitoring and Management

I’m running version 2.3.5, but I’m then struggling to get the pmm-agent to add MySQL monitoring service for a MySQL database that’s hosted in the same server but on another container.

The documentation here seems to only explain if it’s hosted in the same instance: MySQL - Percona Monitoring and Management

Hi, first start pmm-client container as per the doc page:

PMM_SERVER=X.X.X.X:443
docker run \
--rm \
--name pmm-client \
-e PMM_AGENT_SERVER_ADDRESS=${PMM_SERVER} \
-e PMM_AGENT_SERVER_USERNAME=admin \
-e PMM_AGENT_SERVER_PASSWORD=admin \
-e PMM_AGENT_SERVER_INSECURE_TLS=1 \
-e PMM_AGENT_SETUP=1 \
-e PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml \
--volumes-from pmm-client-data \
percona/pmm-client:2

then after starting the PMM Client container, add the mysql service as follows:

docker exec -it <name_of_pmm_client_container> /bin/bash
pmm-admin add mysql --username=<pmm_user> --password=<pmm_pass> --host=<name_of_mysqld_container> --port=<port_of_mysqld_container>

Thanks when I run that command to create the docker container, I know the --rm flag is supposed to indicate short-lived container. When I execute that command to create the container, it’s only running while I have my terminal open, as soon as I exit the terminal. The container is stopped, how do i get it to continiously run? As I plan to have it keep running so I can monitor the MySQL database that’s hosted on another container?

Hi,

Instead of --rm use -d (detached):

I’m having issues adding mysql monitoring to the pmm-agent.

So if I run

docker ps -a

These are the details returned (where MySQL is installed in the container named mysql3) running in port 3308:

f681XXXXXX   percona/pmm-client:2.35.0   "/usr/local/percona/…"   41 minutes ago   Up 41 minutes                                                                        pmm-client
d135XXXXXX   mysql/mysql-server:8.0.35   "/entrypoint.sh mysq…"   5 weeks ago      Up 5 weeks (healthy)   33061/tcp, 0.0.0.0:3308->3306/tcp, 0.0.0.0:33080->33060/tcp   mysql3

So I try to run this command to get pmm-client monitoring the MySQL database that’s hosted in container name “mysql3”:

docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3308

But get this error:

Connection check failed: dial tcp: lookup mysql3 on 13.XX.XXX.XXX: no such host.

So I then tried to supply the ip-address of the server (host) that has the pmm-client and mysql databases hosted in docker containers:

 pmm-admin add mysql --username=test --password=test123 --host=13.XX.XXX.XXX --port=3308

But get the following error:

Connection check failed: dial tcp 13.XX.XXX.XXX:3308: i/o timeout.

Any idea what I’m doing wrong? My server is hosted in AWS, I tried using the ipv4 ip-address and the private one but neither works and give timeout error. I recalled your old percona monitoring software had an option to bind-address, which I don’t see as an option.

it seems your pmm-client container cannot reach your mysql server host/port. Are you sure everything is in the same docker network? do you have anything controlling access to your mysql host and port 3308?

Yesn when I run docker network inspect the network id from the container mysql database is running on and the container pmm-client is runing on both return the same network id. I don’t have anything else controlling access to mysql host and port 3308.

Hi,

Docker ps outputs show the following for the MySQL container:

0.0.0.0:3308->3306/tcp

This means that port 3306 from the container is mapped to 3308 on the host.

You are logging in to the PMM client container, and trying to use port 3308 (the one exposed on the host) with the MySQL container (host = mysql3).

Try using port 3306:

docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3306

If they are indeed in the same docker network, this will work.

1 Like

That didn’t work, I get the same error:

Connection check failed: dial tcp: lookup mysql3 on 172.XX.X.X:53: no such host.

If i run

docker inspect mysql3

I get:

“NetworkSettings”: {
“Bridge”: “”,
“SandboxID”:
“Ports”: {
“3306/tcp”: [
{
“HostIp”: “0.0.0.0”,
“HostPort”: “3308”
}
],
“33060/tcp”: [
{
“HostIp”: “0.0.0.0”,
“HostPort”: “33080”
}
],
“33061/tcp”: null
},

“Networks”: {
“bridge”: {
“NetworkID”: “4abXXXb8”,
}
}

Which matches the network id when I run the same thing for pmm-client container:

docker inspect pmm-client

“Networks”: {
“bridge”: {
“NetworkID”: “4abXXXb8”,
}
}

Hi,

Connection check failed: dial tcp: lookup mysql3 on 172.XX.X.X:53: no such host.

“No such host” means that the docker dns is not being able to resolve “mysql3” as hostname, so there’s something wrong with it.
Can you share the exact commands you used to deploy these two containers? Have you also tried connecting from the pmm-client to the (docker) host and port 3308?

Ok my bad it didn’t look like they were in the same network. Ran these command to fix this issue:

docker network create percona-con
docker network connect percona-con mysql3
docker network connect percona-con pmm-client

Then

docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3306

and that worked!