Skip to content

Jesse's Software Engineering Blog

Jun 13

Jesse

Using Collectd With InfluxDB

Collectd is a Linux daemon used to collect system stats for performance analysis and capacity planning. With a variety of different plugins, collectd can easily be configured to collect data from a variety of different services i.e. MySQL, Apache, etc. This is an overview of how to store collectd data in InfluxDB, which is an open source, scalable time series database.

Collectd Installation

After InfluxDB has been installed, install collectd. To install on Ubuntu 14.04

sudo apt-get update
sudo apt-get install -y collectd collectd-utils

sudo service collectd status

Collectd Configuration

Once collectd has been installed, collectd must be configured to send data to InfluxDB. This is done using the network plugin which is enabled by default but not configured. Find and uncomment the network plugin configuration, setting the server and port to use InfluxDB

# /etc/collectd/collectd.conf
<Plugin network>
   Server "127.0.0.1" "25826"
   # nothing else needs to be uncommented
</Plugin>

InfluxDB Configuration

InfluxDB needs to be configured to accept the collectd stats.

# /opt/influxdb/shared/config.toml 
[input_plugins.collectd]
enabled = true
address = "127.0.0.1"
port = 25826
database = "collectd"
typesdb = "/usr/share/collectd/types.db"

Also the database should be created, which can be done via the browser: http://localhost:8083/

Monitoring Stats

Now that the services have been configured the config files should be reloaded

sudo service influxdb reload
sudo service collectd force-reload

Collectd sends the data to InfluxDB via UDP and can be monitored with the tcpdump command. Note this may take a minute or so to start showing data.

sudo tcpdump -i lo -p -n dst port 25826

Once the data is being sent the data will start to populate in InfluxDB and the collectd database can be queried via the admin UI in the browser: http://localhost:8083/

SELECT * FROM /.*/ limit 100

Conclusion

Collectd offers a large variety of plugins. To activate them simply enable them in the config file (by uncommenting them), and add any customizations in the plugin configuration sections as outlined in the plugin docs. The advantage of using InfluxDB opposed to other backend technologies is that InfluxDB is actively being developed and improved, has support for clustering and horizontal distribution, has a great querying language, and offers easy access to data via a REST API.

Blog Powered By Wordpress