{"id":1194,"date":"2019-07-23T16:33:00","date_gmt":"2019-07-23T11:03:00","guid":{"rendered":"http:\/\/blogs.opstree.com\/?p=1194"},"modified":"2019-09-19T11:58:10","modified_gmt":"2019-09-19T06:28:10","slug":"mysql-monitoring","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2019\/07\/23\/mysql-monitoring\/","title":{"rendered":"MySQL Monitoring"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog1-1.png\" alt=\"\" class=\"wp-image-1197\" \/><\/figure>\n\n\n\n<p>In recent time, I invested a good amount of time in learning and working  on monitoring esp. Database Monitoring. So I found this medium the best  way to share my journey, findings and obviously spectacular dashboards.<br><br> This blog will help you understand why we need MySQL monitoring and how we can do it.<br><br> Let&#8217;s start with the need to implement MySQL monitoring. There are  multiple areas which we can monitor, here I am enlightening some  important ones.<br><br><strong>1. Resource Utilization<\/strong><br> First of all, you have no idea what&#8217;s going on with MySQL, you can not  know if it&#8217;s in a haywire state if there is no monitoring.<br> &nbsp; &nbsp; An ample number of queries run through it. Some of them are  lightweight and some of them are very heavy which makes CPU  over-utilized or overload. In that case, if we talk about production, a  number of requests can be flushed out making it a business loss.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog2.png\" alt=\"\" class=\"wp-image-1199\" width=\"490\" height=\"123\" \/><\/figure>\n\n\n\n<p><strong>2. Database Connections<\/strong><br> Sometimes the number of connections run out and no further connections  are left for application to communicate with DB. In the absence of  monitoring, it&#8217;s really hard to figure out the root cause.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog3.png\" alt=\"\" class=\"wp-image-1200\" width=\"497\" height=\"224\" \/><\/figure>\n\n\n\n<p><strong>3. Replication Lag<\/strong><br> When we use MySQL as a master-slave cluster, real-time replication of  data from the master to slave is a key factor to monitor. The lag  between master and slave should be zero.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog4.png\" alt=\"\" class=\"wp-image-1201\" width=\"502\" height=\"212\" \/><\/figure>\n\n\n\n<p>In my scenario, the slave is being used for DB replication from the \nmaster and also serving read queries to avoid overburden on the master. \nNow if replication lag is high and at the same time if any read query is\n triggered for the slave, what will happen? The same data which is on \nthe master will not get replicated on the slave because of replication \nlag!<br>\nThat read query will show an unexpected or erroneous result.<br><br><strong>4. Query Analytics<\/strong><br>\nMonitoring DB also helps in identify what queries are taking a long \ntime. It helps in identify and optimize slow queries. At the end its all\n about being fast.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog5.png\" alt=\"\" class=\"wp-image-1202\" width=\"517\" height=\"138\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2019\/08\/blog6.png\" alt=\"\" class=\"wp-image-1203\" width=\"516\" height=\"251\" \/><\/figure>\n\n\n\n<p> Ok, so how to monitor MySQL. There are multiple enterprise solutions \navailable to monitor Database with a single click solution, but I didn&#8217;t\n have the luck to go for paid solutions. So, I have started exploring \nopen source solutions which will cover all my requirements. Finally, I \ngot one.<br><br>\nIts <strong>Percona Monitoring And management (PMM)<\/strong>Tool<br><br>\nPMM is an open-source platform to monitor and manage MySQL Database, \nthat we can run in own environment. It provides a time-series database \nwhich ensures reliable and real-time data.<br><br><strong>Installing PMM Server<\/strong><br><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>curl -fsSL https:\/\/raw.githubusercontent.com\/percona\/pmm\/master\/get-pmm.sh&nbsp; -o get-pmm.sh<\/em>\n<\/pre>\n\n\n\n<p>\nChange permission to make it executable<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>chmod +x get-pmm.sh<\/em><\/pre>\n\n\n\n<p>\nNow run pmm script to install it.<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ get-pmm.sh<\/pre>\n\n\n\n<p>\nThis will run a docker container. Once docker container is up and running we will install PMM client and will bind the port<br><br><strong>Installing PMM Client<\/strong><br><br>\nAdd the below repo<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>wget https:\/\/repo.percona.com\/apt\/percona-release_0.1-6.$(lsb_release -sc)_all.deb<\/em><\/pre>\n\n\n\n<p>\nInstall the package from added repository<br><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>dpkg -i percona-release_0.1-6.$(lsb_release -sc)_all.deb<\/em><\/pre>\n\n\n\n<p>\nUpdate your ubuntu follow below steps:<br><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>apt-get update <\/em><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>pmm-admin config --server &lt;server_ip&gt;:&lt;port&gt;-get update <\/em><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>pmm-admin add mysql<\/em><\/pre>\n\n\n\n<p> It&#8217;s  not only MySQL you can monitor, in fact, but pmm also allows to  integrate it with other databases as well like Amazon RDS, Postgres, and  MongoDB.<br><br> There  are many alternatives for MySQL monitoring in the market like Nagios,  VividCortex Analyser, SolarWinds server and application monitor,  LogicMonitor and Management tool, MySQL OpsPack etc. But exploring  open-source tools has its pros and cons but the level of learning you  get from it, that makes it worth using. So anyone out there reading this  blog I would suggest to give it a try.<br><br> Happy monitoring!!<\/p>\n\n\n\n<p><strong>Image Source: <\/strong>https:\/\/www.kisspng.com\/png-clip-art-brand-line-technology-text-messaging-6462820\/preview.html<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In recent time, I invested a good amount of time in learning and working on monitoring esp. Database Monitoring. So I found this medium the best way to share my journey, findings and obviously spectacular dashboards. This blog will help you understand why we need MySQL monitoring and how we can do it. Let&#8217;s start &hellip; <a href=\"https:\/\/opstree.com\/blog\/2019\/07\/23\/mysql-monitoring\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MySQL Monitoring&#8221;<\/span><\/a><\/p>\n","protected":false},"author":171921168,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474,111949,4419,11987323],"tags":[27440332,604065510,685617147,1997446],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-jg","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/1194"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/171921168"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=1194"}],"version-history":[{"count":4,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/1194\/revisions"}],"predecessor-version":[{"id":1210,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/1194\/revisions\/1210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=1194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=1194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=1194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}