I’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’m aware that is a python plugin that could add support for this, but I’ve decided to give telegraf a try.
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.
Installing telegraf
Because I’m on debian, I’ve opted to add the apt reporsitory from InfluxData to my system, so that updating in the future is a breeze.
Everything is well documented on InfluxData’s help pages, but here is what I’ve gone through:
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - source /etc/os-release test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
Next, the usual update and install
sudo apt-get update sudo apt-get install telegraf
This immediately started the telegraf monitor with the default settings, so on to /etc/telegraf/telegraf.conf for some modifications…
The default configuration had InfluxDB output enabled, but on localhost. I modified it to have this:
[[outputs.influxdb]] ## The full HTTP or UDP endpoint URL for your InfluxDB instance. ## Multiple urls can be specified as part of the same cluster, ## this means that only ONE of the urls will be written to each interval. urls = ["http://monitor.xxxxxx.xxx:8086"] # required ## The target database for metrics (telegraf will create it if not exists). database = "telegraf"
You can optionally also configure additional security through the use of username/password or via an SSL certificate. Also don’t forget to setup your influxdb machine to only accept metrics data from your known hosts via firewall settings.
Setting up monitoring for mysql or mariadb was equally straightforward:
[[inputs.mysql]] servers = ["debian-sys-maint:xxxxxxxxxx@tcp(127.0.0.1:3306)/"]
As you can see, I’m using the debiam sys-maintenance user. You can alternatively create a specific database user for this.
After restarting telegraf, metrics started flowing in on InfluxDB.
Charting data
The data gathered by the mysql plugin was easy to use, and hence I ended up with, among others, this chart panel in Grafana.
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.