{"id":6,"date":"2016-10-10T03:48:21","date_gmt":"2016-10-10T03:48:21","guid":{"rendered":"http:\/\/wp452m.a10-52-158-154.qa.plesk.ru\/wordpress\/?p=1"},"modified":"2025-10-11T07:44:17","modified_gmt":"2025-10-11T07:44:17","slug":"hello-world-2","status":"publish","type":"post","link":"https:\/\/groots.be\/?p=6","title":{"rendered":"Monitoring with Collectd, InfluxDB and Grafana"},"content":{"rendered":"<p>For a long while, I&#8217;ve used munin along with a few custom made munin plugins to monitor a server of mine. Recently however, there&#8217;s been a few interesting new offerings on the market that aim to make monitoring more flexible, so I decided to give it a go.<\/p>\n<p>I quickly ended up with collectd as the monitoring agent, given it&#8217;s extremely lightweight, around for more than 10 years. It also supports sending its collected data in numerous different formats, making my choice on the server side more or less independent.<\/p>\n<p>For starters, I tried the ELK stack. However, given that I&#8217;m particularly conscious of resource usage, I had to eliminate this early on. In my setup, with which I&#8217;m using a sole and small monitoring server, it was impossible to get ElasticSearch to run for more than a couple of days before running out of heap space. The week that I&#8217;ve been running and testing it though made me realise Kibana is just too complex to configure, given that all I need is something similar to my good old and simple munin.<\/p>\n<p>Having done more experiments with Graphite (a bit complex to setup), and collectd with GraphZ (more or less similar output as with munin), I ended up installing InfluxDB and Grafana.<\/p>\n<h2>Installing influxDB<\/h2>\n<p>Since I&#8217;m on Debian, I&#8217;m doing the following, in line with the <a href=\"https:\/\/influxdata.com\/downloads\/\">downloads page<\/a>:<\/p>\n<pre>$ sudo dpkg -i influxdb_1.1.0_amd64.deb\n<code>\n<\/code><\/pre>\n<p>This installs the service influxdb, with the CLI executable available at \/usr\/bin\/influx. The configuration file can be found at \/etc\/influxdb\/influxdb.conf.<\/p>\n<p>The latter must be modified first, to enable gather metrics coming from collectd agents.<\/p>\n<pre>[collectd]\n    enabled = true\n    bind-address = \"127.0.0.1:25826\"\n    database = \"collectd\"\n    typesdb = \"\/usr\/share\/collectd\/\"\n\nNote that you need to change the template value of the enabled property to true (apart from uncommenting). I have also had to modify the typesdb property to a directory, telling InfluxDB to load all files as types.db definitions. This is necessary if you have custom types (which you'd define in collecd.conf with separate typedb properties).<\/pre>\n<p>Next, we start the service, enabling influxdb to start gathering metrics on collectd&#8217;s default port:<\/p>\n<pre><code>sudo service influxdb start<\/code><\/pre>\n<p>You can subsequently check if metrics are succesfully retrieved by InfluxDB as follows:<\/p>\n<pre>$ sudo influx -precision rfc3339<code class=\" language-markup\">\n<\/code><code class=\" language-markup\"><\/code>Visit https:\/\/enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.\nConnected to http:\/\/localhost:8086 version 1.1.0 InfluxDB shell version: 1.1.0 \n&gt; use collectd \nUsing database collectd \n&gt; show measurements \nname: measurements \nname \n---- \napache_value \ncpu_value \ncurl_json_value \ncurl_value \ndf_value \ndisk_read<\/pre>\n<p>(Note how I added the rfc3339 precision, to make sure that timestamps in the measurements are readable)<\/p>\n<p>If you have no measurements listed, you&#8217;ll have to work out where things are going wrong. Chances are you need to open up the firewall to accept incoming traffic on the collectd port.<\/p>\n<p>So far so good. Metrics are being gathered, but we obviously need to seem the as well. This is where the Grafana dashboard comes in. I&#8217;ll use this, rather than the recently <a href=\"https:\/\/www.influxdata.com\/announcing-the-new-chronograf-a-ui-for-the-tick-stack-and-a-complete-open-source-monitoring-solution\/\">open-sourced<\/a> Chronograph, as it is still more feature rich. There&#8217;s still room to switch over later on while retaining InfluxDB as the data container.<\/p>\n<h2>Installing Grafana<\/h2>\n<p>Just like with Influx, the <a href=\"http:\/\/docs.grafana.org\/installation\/debian\/\">documentation<\/a> is clear. I decided to use the APT repository. For Debian, I have to add the grafana repository to my \/etc\/apt\/sources.list , but on Ubuntu 16.04, Grafana can be installed from the available packages:<\/p>\n<pre><code>$ sudo apt-get update\n$ sudo apt-get install grafana<\/code><\/pre>\n<p>Start up the service:<\/p>\n<pre>$ sudo service grafana-server start<\/pre>\n<p>By default, this starts the grafana web interface on port 3000, so you could go and check grafana at http:\/\/localhost:3000.<\/p>\n<p>I found this a bit impractical, and therefore decided to proxy it through nginx. For this, I needed to adapt both the configuration of grafana, as well as of nginx.<\/p>\n<p>I added the following to my \/etc\/nginx\/sites-enabled\/nginx.conf file:<\/p>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location \/grafana\/ {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 proxy_pass\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 http:\/\/127.0.0.1:3000\/;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/pre>\n<p>And in \/etc\/grafana\/grafana.conf, modified the root_url property:<\/p>\n<p>root_url = %(protocol)s:\/\/%(domain)s:%(http_port)s\/grafana<\/p>\n<p>Restart both to apply the changes, after which I could navigate to localhost\/grafana to see the grafana login screen.<\/p>\n<pre>$ sudo service grafana-server start\n$ sudo service nginx restart<\/pre>\n<p>The default login for grafana is admin \/ admin, but you can change this in the grafana configuration file. Once logged in, you&#8217;ll need to add your data source. For me, the settings look as follows:<\/p>\n<div id=\"attachment_10\" style=\"width: 277px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-10\" class=\"size-medium wp-image-10\" src=\"https:\/\/groots.be\/wp-content\/uploads\/2016\/05\/grafana-influxdb-datasource-277x300.png\" alt=\"InfluxDB datasource configuration\" width=\"277\" height=\"300\" srcset=\"https:\/\/groots.be\/wp-content\/uploads\/2016\/05\/grafana-influxdb-datasource-277x300.png 277w, https:\/\/groots.be\/wp-content\/uploads\/2016\/05\/grafana-influxdb-datasource.png 554w\" sizes=\"auto, (max-width: 277px) 100vw, 277px\" \/><p id=\"caption-attachment-10\" class=\"wp-caption-text\">InfluxDB datasource configuration<\/p><\/div>\n<p>This brings us to a point where we can start setting up some graphs in Grafana. I&#8217;ll follow this up with some example graphs in a new post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a long while, I&#8217;ve used munin along with a few custom made munin plugins to monitor a server of mine. Recently however, there&#8217;s been a few interesting new offerings on the market that aim to make monitoring more flexible, so I decided to give it a go. I quickly ended up with collectd as&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":[3,4,5,6,8],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-devops","tag-grafana","tag-influxdb","tag-linux","tag-monitoring"],"_links":{"self":[{"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/6","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=6"}],"version-history":[{"count":1,"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":52,"href":"https:\/\/groots.be\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions\/52"}],"wp:attachment":[{"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/groots.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}