etsy/statsd — Issue #49: configurable key patterns
Author: omry
Created: 2011-12-26 15:01:06+00:00
State: open

in my architecture, I run statsd on each server, and they all send to a central graphite server, so it makes sense that each statsd prepands the hostname (in reverse) to the key.

I have made the key sent by statsd configurable.

this is available in my repo (omry/statsd), if you are interested I`ll create a pull request.

this is implemented by adding a few more configuration.
here is my example config.

/*

Required Variables:

graphiteHost: hostname or IP of Graphite server
graphitePort: port of Graphite server
port: StatsD listening port [default: 8125]

Optional Variables:

debug: debug flag [default: false]
debugInterval: interval to print debug information [ms, default: 10000]
dumpMessages: log all incoming messages
flushInterval: interval (in ms) to flush to Graphite
percentThreshold: for time information, calculate the Nth percentile
[%, default: 90]
patterns:
all patterns are optional (default values are reasonable).
patterns may contain special variables which are replaced by actual data:
${hostname} : will be replaced by the reversed hostname, if the hostname is www.example.com, the ${hostname} variable will be replaced by com.example.www
${key} : key provided by client library

stats_pattern: pattern used when creating user data keys, for example servers.${hostname}.${key}
stats_timers_pattern: pattern used when creating timer keys, for example "servers.${hostname}.timers.${key}"
statsd_pattern: pattern used when creating keys used for statsd statistics, for example "servers.${hostname}.statsd.${key}"
stats_count_pattern: pattern used when creting keys used for stats counters, for example servers.${hostname}.stats_count.${key}

*/

{
graphitePort : 2003
, graphiteHost : "carbon"
, port : 8125
, stats_pattern : "servers.${hostname}.${key}"
, stats_timers_pattern : "servers.${hostname}.timers.${key}"
, statsd_pattern : "servers.${hostname}.statsd.${key}"
, stats_count_pattern : "servers.${hostname}.stats_count.${key}"
}