{"id":13,"date":"2016-11-29T21:24:33","date_gmt":"2016-11-29T21:24:33","guid":{"rendered":"https:\/\/www.groots.be\/?p=13"},"modified":"2025-10-11T07:44:17","modified_gmt":"2025-10-11T07:44:17","slug":"monitoring-mysql-mariadb-with-telegraf","status":"publish","type":"post","link":"https:\/\/groots.be\/?p=13","title":{"rendered":"Monitoring mysql \/ mariadb with telegraf"},"content":{"rendered":"<p>I&#8217;m currently monitoring most of the processes that I need info about with collectd, but it seems that the default mysql plugin does not support metrics related to innodb. I&#8217;m aware that is a python plugin that could add support for this, but I&#8217;ve decided to give telegraf a try.<\/p>\n<p>Telegraf is a metrics gathering tool written in Go, hence distributed as a single executable. It was designed to be easily extendable, and has a minimal memory footprint.<\/p>\n<h2>Installing telegraf<\/h2>\n<p>Because I&#8217;m on debian, I&#8217;ve opted to add the apt reporsitory from InfluxData to my system, so that updating in the future is a breeze.<\/p>\n<p>Everything is well documented on <a href=\"https:\/\/docs.influxdata.com\/influxdb\/v1.1\/introduction\/installation\/#installation\">InfluxData&#8217;s help pages<\/a>, but here is what I&#8217;ve gone through:<\/p>\n<pre>curl -sL https:\/\/repos.influxdata.com\/influxdb.key | sudo apt-key add -\nsource \/etc\/os-release\ntest $VERSION_ID = \"7\" &amp;&amp; echo \"deb https:\/\/repos.influxdata.com\/debian wheezy stable\" | sudo tee \/etc\/apt\/sources.list.d\/influxdb.list\ntest $VERSION_ID = \"8\" &amp;&amp; echo \"deb https:\/\/repos.influxdata.com\/debian jessie stable\" | sudo tee \/etc\/apt\/sources.list.d\/influxdb.list<\/pre>\n<p>Next, the usual update and install<\/p>\n<pre>sudo apt-get update\nsudo apt-get install telegraf<\/pre>\n<p>This immediately started the telegraf monitor with the default settings, so on to \/etc\/telegraf\/telegraf.conf for some modifications&#8230;<\/p>\n<p>The default configuration had InfluxDB output enabled, but on localhost. I modified it to have this:<\/p>\n<pre>[[outputs.influxdb]]\n\u00a0 ## The full HTTP or UDP endpoint URL for your InfluxDB instance.\n\u00a0 ## Multiple urls can be specified as part of the same cluster,\n\u00a0 ## this means that only ONE of the urls will be written to each interval.\n\u00a0 urls = [\"http:\/\/monitor.xxxxxx.xxx:8086\"] # required\n\u00a0 ## The target database for metrics (telegraf will create it if not exists).\n\u00a0 database = \"telegraf\"<\/pre>\n<p>You can optionally also configure additional security through the use of username\/password or via an SSL certificate. Also don&#8217;t forget to setup your influxdb machine to only accept metrics data from your known hosts via firewall settings.<\/p>\n<p>Setting up monitoring for mysql or mariadb was equally straightforward:<\/p>\n<pre>\u00a0[[inputs.mysql]]\n\u00a0\u00a0 servers = [\"debian-sys-maint:xxxxxxxxxx@tcp(127.0.0.1:3306)\/\"]<\/pre>\n<p>As you can see, I&#8217;m using the debiam sys-maintenance user. You can alternatively create a specific database user for this.<\/p>\n<p>After restarting telegraf, metrics started flowing in on InfluxDB.<\/p>\n<h2>Charting data<\/h2>\n<p>The data gathered by the mysql plugin was easy to use, and hence I ended up with, among others, this chart panel in Grafana.<\/p>\n<p><a href=\"https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-19\" src=\"https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-1024x408.png\" alt=\"grafana-mysql-qcache\" width=\"710\" height=\"283\" srcset=\"https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-1024x408.png 1024w, https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-300x120.png 300w, https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-768x306.png 768w, https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-1536x612.png 1536w, https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache-1568x625.png 1568w, https:\/\/groots.be\/wp-content\/uploads\/2016\/11\/grafana-mysql-qcache.png 1859w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/a><\/p>\n<p>All in all, this was an immediate upside of telegraf for me, which triggered me to explore more of its plugins, and perhaps use some of them instead of their collectd counterparts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m currently monitoring most of the processes that I need info about with collectd, but it seems that the default mysql plugin does not support metrics related to innodb. I&#8217;m aware that is a python plugin that could add support for this, but I&#8217;ve decided to give telegraf a try. Telegraf is a metrics gathering&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,6,7,8,9],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-grafana","tag-linux","tag-mariadb","tag-monitoring","tag-mysql"],"_links":{"self":[{"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":1,"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":51,"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/51"}],"wp:attachment":[{"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}