Monitor server with CollectD, InfluxDB and Grafana

In the software development, Monitor is a big feature we need to concern. It is not only for monitoring the production. But we also need to monitor your testing environment (e.g for performance test, stress test). So in this post, I will show you how to monitor server with CollectD, InfluxDB and Grafana.

At the first, we have to install CollectD in the agent machine. In my case, the agent machine also uses Ubuntu 14.04. And we have to install CollectD version 5.5.0+. Why? Because all the versions easier 5.5.0, Plugin cpu of CollectD only use jitters metric that we can not show properly in Grafana.

Gopher and Gun T-Shirt

Gopher and Gun T-Shirt

My scenario is:

  • I have 2 servers installed Ubuntu 14.04
  • One at address 192.168.1.194. And the other one is 192.168.1.192 that we need to monitor
  • They can ping each others.
Collectd Grafana InfluxDB

We will monitor server 192.168.1.192 with CollectD

So now, Install CollectD to Server 192.168.1.192.

CollectD

I recommend you install CollectD from the source code to make sure that you are using the correct version.

Before running build the packet from source code, we need to install the dependencies:

(libcurl4-gnutls-dev to enable curl and nginx plugin)

Edit /opt/collectd/etc/collectd.conf to enable CollectD collect cpu data with percentage instead of jitters:

And enable network plugin to push monitor data to InfluxDB at address 192.168.1.194, port 25826

Restart CollectD

Debug:

And now, we install InfluxDB and Grafana in Server 192.168.1.194

InfluxDB

Install with dpkg command:

InfluxDB Web run on port 8083, so you access web at address http://192.168.1.194:8083 and create collectd database:

Edit /etc/influxdb/influxdb.conf to enable collectd. See the content below:

Please make note that with the configuration above we use port 25826 on UDP to receive monitor data that pushed from CollectD

And the next step,  restart InfluxDb:

For troubleshoot the issue with InfluxDB, we can view logs:

Grafana

Download and install via dpkg command:

If you meet an error as below:

You can correct it by the commands:

 

Grafana run on port 3000. So you can access via link http://192.168.1.194:3000.

To connect InfluxDb,  you follow the path: Grafana => Data Source => Add New => And Input the information as the image below:

25-11-2015 3-22-51 CH

Grafana connects to InfluxDB (default account root/root)

After that, create New Dash Board => New Panel => Graph as image below:

28-11-2015 7-31-40 CH

Grafana + CollectD CPU (percentage)

I created a new dashboard that help me monitor CPU and RAM:

25-11-2015 4-19-02 CH

Grafana, CollectD and InfluxDB

Tips

To collect interface data in bytes per second we should use:

 

  • longkyanh

    good to know this, anw I still prefer UI from terminal, fast and effectively 😉

  • Pingback: InfluxDB Week in Review – Dec 18, 2015 | InfluxData()

  • Graham McMillan

    Thanks for the tutorial. However influxdb wouldn’t run for me until i installed collectd on its server. Kept complaining about not being able to find /usr/share/collectd/.