Since version 5.4, CollectD implements theAi??StatsD network protocol. This means that you might not need to run two separate processes anymore.
About StatsD inAi??CollectD
StatsDAi??and CollectD are complementaryAi??monitoring solutions:
- Stats is an event counter/aggregation service. SimplyAi??send events toAi??this external service to monitorAi??yourAi??own code. The aggregated events are periodically sentAi??to a database.
- CollectDAi??is a statistics collection daemon. It periodically polls various sources, such as your OS, CPU, RAM, and network, but also many databases and software.
StatsD is alsoAi??”embedded” intoAi??CollectD since v5.4Ai??with the StatsD plugin.Ai??CollectD can now act as a StatsD process.
InstallAi??StatsD Plugin for CollectD
Edit the CollectD configuration file usually located at /opt/collectd/etc/collectd.conf
Uncomment or add StatsD plugin and configuration:
Don’t forget to restart CollectD:
$ service collectd restart
- Host “0.0.0.0”: Listen toAi??any IP. Change to “127.0.0.1” to only allow localhost to send metrics.
- port 8125: Where StatsD metrics will be received.
- DeleteSets true: The values ofAi??type setsAi??metricsAi??will not be sent if they didn’t change since the last interval.
Read more about StatsD plugin configuration.
Many StatsD client libraries exist in various programming languages. Pick your favorite and call StatsD on port 8125. It’s also possible to call the plugin from the command line:
$ echo "my.own.metric:1|c" | nc -w 1 -u 127.0.0.1 8125
$ echo "my.own.metric:4|c" | nc -w 1 -u 127.0.0.1 8125
If, like us, your CollectD sends its metrics to InfluxDB, you should see the values in your database.
Calling both commands:
- Within the interval will result in an aggregate value of 5
- Out of the interval will result in two values: 4 and 1
StatsD is aAi??veryAi??clever idea implemented in simple software. ItAi??behavior wasAi??replicated inAi??730 lines of C.
This Plugin is stable and was able to achieve 50k events per second on commodity hardware. IfAi??youAi??already run CollectD and don’t need to run StatsD at scale it is highlyAi??recommended that you use this plugin to save yourself the pain of running both services.