Proper way to monitor a MySQL container by PMM

What’s the proper way to set monitoring a MySQL container (or several different MySQL containers), installed at one pmm client host ?

best regards,
Avi Vainshtein

Hi avi vainshtein
Can you tell us a little more about your environment? Do you mean you are running MySQL in a docker container? If you forward the port 3306/tcp then you can use pmm-admin to add just the MySQL metrics & queries (example only, adapt to your IP addresses):

pmm-admin add mysql:metrics --host=172.17.0.1 --port=3306
pmm-admin add mysql:queries --host=172.17.0.1 --port=3306

Or you can use the Agentless MySQL feature from 1.16 and not have to install pmm-client anywhere! Have a look at our docs: https://www.percona.com/doc/percona-…-instance.html

Hello @Michael Coburn,

We have two PMM-related hosts , both running CentOS Linux 7.5.

H1 : with PMM 1.17 server, running as docker/container.

H2: client host.
It has a “regular” rpm MySQL 5.7.23 database installation.
PMM client rpm 1.17 was installed at that host.

Using command like “pmm-admin add mysql --user root --password XXXXXXXX” i’ve managed to add that regular-rpm-MySQL database to be seen
at PMM server, and it works fine, and it’s contents can be seen from PMM Server Web Inerface.

[root@vm-tskapin2 ~]# pmm-admin list
pmm-admin 1.17.0

PMM Server | 10.236.151.48:80
Client Name | vm-tskapin2
Client Address | 10.236.151.49
Service Manager | linux-systemd


SERVICE TYPE NAME LOCAL PORT RUNNING DATA SOURCE OPTIONS


mysql:queries vm-tskapin2 - YES root:@unix(/var/lib/mysql/mysql.sock) query_source=perfschema, query_examples=true
linux:metrics vm-tskapin2 42000 YES -
mysql:metrics vm-tskapin2 42002 YES root:
@unix(/var/lib/mysql/mysql.sock)

Additionally, at the same client host H2 there are few MySQL containers :
[root@vm-tskapin2 ~]# docker ps -a|grep mysql
d25a78ace5bb mysql:5.7 “docker-entrypoint.s⦔ 2 weeks ago Up 2 weeks 33060/tcp, 0.0.0.0:6000->3306/tcp mysqlDB_dev2
cd27d38018e0 centos/mysql-57-centos7 “container-entrypoin⦔ 2 weeks ago Up 2 weeks 0.0.0.0:7000->3306/tcp mysqlDB_dev
81e58c3073ee mysql-pxb3:5.6 “docker-entrypoint.s⦔ 2 weeks ago Up 2 weeks 0.0.0.0:1000->3306/tcp mysqlTST5
8587a43b6aef mysql-pxb2:5.6 “docker-entrypoint.s⦔ 3 weeks ago Up 3 weeks 0.0.0.0:5000->3306/tcp mysqlTST2
aeb37f568206 mysql-pxb:5.6 “docker-entrypoint.s⦔ 3 weeks ago Up 3 weeks 0.0.0.0:2000->3306/tcp mysqlDEV
d21c7630959e mysql:5.6 “docker-entrypoint.s⦔ 3 weeks ago Up 3 weeks 0.0.0.0:4000->3306/tcp mysqlTST
be00d24a2c3d mysql:5.6 “docker-entrypoint.s⦔ 3 weeks ago Up 2 weeks 0.0.0.0:3000->3306/tcp mysql

I would like to allow PMM server Web Interface to present those MySQL containers also.
So, i ran the command :
[root@vm-tskapin2 ~]# pmm-admin add mysql --host vm-tskapin2 --port 3000 --user root --password my-secret-pw mysql_container_3000
[linux:metrics] OK, already monitoring this system.
[mysql:metrics] OK, now monitoring MySQL metrics using DSN root:@tcp(vm-tskapin2:3000)
[mysql:queries] OK, now monitoring MySQL queries from perfschema using DSN root:
@tcp(vm-tskapin2:3000)

And since then - that container mysql_container_3000 does appear in the output of pmm-admin list command :
[root@vm-tskapin2 ~]# pmm-admin list
pmm-admin 1.17.0

PMM Server | 10.236.151.48:80
Client Name | vm-tskapin2
Client Address | 10.236.151.49
Service Manager | linux-systemd


SERVICE TYPE NAME LOCAL PORT RUNNING DATA SOURCE OPTIONS


mysql:queries mysql_container_3000 - YES root:@tcp(vm-tskapin2:3000) query_source=perfschema, query_examples=true
mysql:queries vm-tskapin2 - YES root:
@unix(/var/lib/mysql/mysql.sock) query_source=perfschema, query_examples=true
linux:metrics vm-tskapin2 42000 YES -
mysql:metrics vm-tskapin2 42002 YES root:@unix(/var/lib/mysql/mysql.sock)
mysql:metrics mysql_container_3000 42003 YES root:
@tcp(vm-tskapin2:3000)

However, that MySQL container’s information does not appear in the PMM Server’s Web Interface contents .

What did i miss ?

Best regards,
Avi

Hi avi vainshtein

You should be able to keep adding each container’s mysqld activity using the method you described, namely:

pmm-admin add mysql --host vm-tskapin2 --port 3000 --user root --password my-secret-pw mysql_container_3000
pmm-admin add mysql --host vm-tskapin2 --port 2000 --user root --password my-secret-pw mysql_container_2000

With regards to host activity within the container, unfortunately you will only get host level at the level where dockerd is running.

I suppose you could install node_exporter inside each of the mysqld containers you have… then you could expose those ports and scrape them and relate them back to the mysql instance.