Collectd

From Nix-Pro
Jump to: navigation, search

Introduction

Collectd is a small Unix daemon written on C that can collect various system and services performance statistics and provides ways to store the values in a variety of formats (e.g. RRD files or Graphite), send them over a network or proxy to other services (e.g. Logstash).

It's important to understand Collectd doesn't do anything but itself and all the functionality is provided by different plugins also written on C. So, the configuration of Collectd service can be nailed down to the configuration of the plugins you want to use to monitor the system.

The plugins can be split into: input and output plugins. Input plugins can read metrics from either system or some services (e.g. Apache), the output plugins can store this information in RRD files, Graphite, etc or pass it to another service for example Logstash.

Quick start guide

In this example we will:

  • Get memory usage metrics from Collectd using appropriate memory plugin
  • Send the metrics using Collectd network plugin to Logstash
  • Output metrics received from Collectd to stdout using Logstash

Memory plugin in this case will be input plugin and network plugin will be output plugin.

Collectd configuration

  • main config file
vim /etc/collectd/collectd.conf
#
FQDNLookup false

<Include "/etc/collectd/collectd.conf.d">
        Filter "*.conf"
</Include>

Some other generic useful options:

  • Interval 1 - Collectd will record the server performance every second. By default it is set to 10 seconds but for quick anomaly detection 1 second is better. It allow to detect problems much faster.

Load memory plugin

  • add memory plugin config
vim  /etc/collectd/collectd.conf.d/network.conf
#
LoadPlugin memory

Load network plugin

Logstash configuration

Troubleshooting

Used Documentation

https://collectd.org/wiki/index.php/Networking_introduction
https://collectd.org/wiki/index.php/Naming_schema