A simple statistics collector, written in Google Go.
First make sure you have the a working Go environment. See the install instructions. MetricsD will always compile on the
Then you will be able to clone and compile MetricsD:
git clone --recursive --branch release git://github.com/kpumuk/metricsd.git cd metricsd make install
By default MetricsD will be install to the
/usr/local/metricsd directory. To change it, use
DESTINATION environment variable with
DESTINATION=/opt/metricsd make install
Please note: if you want to run
make install with
sudo, make sure that root user has all Go environment variables defined. Also you can use
-E switch to preserve your current environment (needs
setenv option set in
sudo -E make install
Configuration is stored in JSON format, and you can find an example in
metricsd.conf.example. Every config option could be overridden using command-line arguments. Following options available at the moment:
-listen) — set the port (+optional address) to listen at. Default is
-data) — set the data directory. Default is
-debug) — set the debug level, the lower - the more verbose (0-5). Default is
-slice) — set the slice interval in seconds. Default is
-write) — set the write interval in seconds. Default is
-batch) — set the value indicating whether batch RRD updates should be used. Default is
-lookup) — set the value indicating whether reverse DNS lookup should be performed for sources.
Another command-line options:
-test— validate the configuration file and exit.
-config— path to the configuration file.
MetricsD uses very simple UDP-based protocol for collecting metrics. Here is what it looks like:
metric:value— in this simplest case value will be collected in several RRD files; for each writer (see below) two files will be created:
writeris a name of writer,
IP— an IP address of the source host,
metric— metric name.
source@metric:value— the same as previous, but instead of IP address of the source host,
sourcewill be used. If it's equal to
all, no per-host RRD file will be created, only summary for all ones.
metric:value;source@metric:value— it's possible to send several metrics update in a single packet. Please note: you have to specify
sourcefor every metric (metrics without source will be saved to IP-based RRD files).
group$metric:value— metrics could be grouped in UI based on the
response_time:153 all/response_time-quartiles.rrd, 10.0.0.1/response_time-quartiles.rrd, all/response_time-yesno.rrd, 10.0.0.1/response_time-yesno.rrd app01@response_time:153 all/response_time-quartiles.rrd, app01/response_time-quartiles.rrd, all/response_time-yesno.rrd, app01/response_time-yesno.rrd all@response_time:153 all/response_time-quartiles.rrd, all/response_time-yesno.rrd app01@response_time:153;all@requests:-1 all/response_time-quartiles.rrd, app01/response_time-quartiles.rrd, all/response_time-yesno.rrd, app01/response_time-yesno.rrd, all/requests-quartiles.rrd, all/requests-yesno.rrd
Writer is an implementation of a metrics aggregation algorithm. Each writer generates an RRD file with different (most probably) datasources and RRAs to store aggregated metrics.
There are two writers currently implemented:
count— calculates number of successful (value >
0) and failes (value <
0) events. Data sources:
ok— number of successful events,
fail— number of failed events.
quartiles— calculates quartiles for input data. Creates following data sources:
total(number of samples).
percentiles— calculates 90th and 95th percentiles for input data, along with mean value and standard deviation for values under the percentile. Creates following data sources:
pct90mean(mean of values under 90th percentile),
pct90dev(standard deviation of values under 95th percentile),
pct95mean(mean of values under 95th percentile),
pct95dev(standard deviation of values under 95th percentile).