# Proper way to monitor a MySQL container by PMM

**URL:** <https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718>\
**Category:** PMM 1.x\
**Created:** [December 3, 2018, 5:43am UTC](https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718 "2018-12-03T05:43:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![avi\_vainshtein](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@avi\_vainshtein](https://forums.percona.com/u/avi_vainshtein)\
**Post date:** [December 3, 2018, 5:43am UTC](https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718/1 "2018-12-03T05:43:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_Coburn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/michael_coburn/32/18_2.png) [@Michael\_Coburn](https://forums.percona.com/u/Michael_Coburn)\
**Post date:** [December 12, 2018, 10:23am UTC](https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718/2 "2018-12-12T10:23:45Z")

</div>

Hi [avi vainshtein](https://percona.vanillacommunities.com/profile/x/x/31112)  
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):

```auto
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-](https://www.percona.com/doc/percona-)…-instance.html

---

<div class="post-metadata">

**Author:** ![avi\_vainshtein](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@avi\_vainshtein](https://forums.percona.com/u/avi_vainshtein)\
**Post date:** [December 18, 2018, 3:26am UTC](https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718/3 "2018-12-18T03:26:24Z")

</div>

Hello @[Michael Coburn](https://www.percona.com/forums/member/22577-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

---

<div class="post-metadata">

**Author:** ![Michael\_Coburn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/michael_coburn/32/18_2.png) [@Michael\_Coburn](https://forums.percona.com/u/Michael_Coburn)\
**Post date:** [February 4, 2019, 3:21pm UTC](https://forums.percona.com/t/proper-way-to-monitor-a-mysql-container-by-pmm/6718/4 "2019-02-04T15:21:19Z")

</div>

Hi [avi vainshtein](https://percona.vanillacommunities.com/profile/x/x/31112)

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.
