Skip to content
/ statsd Public
forked from statsd/statsd

Simple daemon for easy stats aggregation

License

Notifications You must be signed in to change notification settings

oli99sc/statsd

 
 

Repository files navigation

StatsD

A network daemon for aggregating statistics (counters and timers), rolling them up, then sending them to graphite.

We (Etsy) blogged about how it works and why we created it.

Concepts

  • buckets Each stat is in it's own "bucket". They are not predefined anywhere. Buckets can be named anything that will translate to Graphite (periods make folders, etc)

  • values Each stat will have a value. How it is interpreted depends on modifiers

  • flush After the flush interval timeout (default 10 seconds), stats are munged and sent over to Graphite.

Counting

gorets:1|c

This is a simple counter. Add 1 to the "gorets" bucket. It stays in memory until the flush interval.

Timing

glork:320|ms

The glork took 320ms to complete this time. StatsD figures out 90th percentile, average (mean), lower and upper bounds for the flush interval.

Sampling

gorets:1|c|@0.1

Tells StatsD that this counter is being sent sampled every 1/10th of the time.

Guts

  • UDP Client libraries use UDP to send information to the StatsD daemon.

  • NodeJS

  • Graphite

Graphite uses "schemas" to define the different round robin datasets it houses (analogous to RRAs in rrdtool). Here's what Etsy is using for the stats databases:

[stats]
priority = 110
pattern = ^stats\..*
retentions = 10:2160,60:10080,600:262974

That translates to:

  • 6 hours of 10 second data (what we consider "near-realtime")
  • 1 week of 1 minute data
  • 5 years of 10 minute data

This has been a good tradeoff so far between size-of-file (round robin databases are fixed size) and data we care about. Each "stats" database is about 3.2 megs with these retentions.

Installation and Configuration

  • Install node.js

  • Clone the project

  • Create a config file from exampleConfig.js and put it somewhere

  • Start the Daemon:

    node stats.js /path/to/config

Configuration Options

  • measureByIP

If set in config file, each counter and timer will be measured and accumulated additionally by the IP address statds received the UDP package from. To compensate for the fact that graphite can not cope with nodes and directories with the same name, the string ".all" is added to the key for the over all aggregates.

If nodes 192.168.22.1 and 192.168.22.13 send in a counter with key "foo.bar" this will result in values for keys:
stats.foo.bar.all : with the aggregated values over all servers stats.foo.bar.192-168-22-1 : for measures of host with ip 192.168.22.1 stats.foo.bar.192-168-22-13 : measures of host with ip 192.168.22.13

Inspiration

StatsD was inspired (heavily) by the project (of the same name) at Flickr. Here's a post where Cal Henderson described it in depth: Counting and timing. Cal re-released the code recently: Perl StatsD

Contribute

You're interested in contributing to StatsD? AWESOME. Here are the basic steps:

fork StatsD from here: http://github.com/etsy/statsd

  1. Clone your fork
  2. Hack away
  3. If you are adding new functionality, document it in the README
  4. If necessary, rebase your commits into logical chunks, without errors
  5. Push the branch up to GitHub
  6. Send a pull request to the etsy/statsd project.

We'll do our best to get your changes in!

Contributors

In lieu of a list of contributors, check out the commit history for the project: http://github.com/etsy/statsd/commits/master

About

Simple daemon for easy stats aggregation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 34.0%
  • Java 22.9%
  • PHP 15.8%
  • Python 14.2%
  • Shell 13.1%