Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Statsd introduction

3,166 views

Published on

StatsD is a front-end proxy to send calcuated time series data to Graphite/Carbon server.

Published in: Travel

Statsd introduction

  1. 1. StatsD Introduction Rick chang
  2. 2. Agenda History! Architecture! Concept! Demo! Implementation
  3. 3. History StatsD is a front-end proxy for the Graphite/ Carbon metrics server.! Originally written by Etsy’s Erik Kastner! The first idea from Flickr by Cal Henderson! Implemented in Node
  4. 4. StatsD in many languages Flickr’s StatsD: Perl. The real original statsd from 2008.! Etsy’s statsd: Node.js. The new statsd.! petef-statsd: Ruby. Supports AMQP.! quasor/statsd: Ruby. can send data to graphite or mongoDB! py-statsd: Python (including python client code).! statsd.scala: Scala. Sends data to Ganglia instead of Graphite. Different messaging protocol, uses JSON.! statsd-c: C. compatible with original etsy statsd! bucky: Python. A small server for collecting and translating metrics for Graphite. It can current collect metric data from CollectD daemons and from StatsD clients. Reference: http://www.joemiller.me/2011/09/21/list-of-statsd-server-implementations/
  5. 5. Architecture Your App send data to StatsD by UDP port 8125! StatsD send data to Carbon by TCP port 2003
  6. 6. Metric Types Count [key]:[value]|c! sample.counter:1|c! At each flush the current count is sent and reset to 0! Sampling! sample.counter:1|c@0.1! sent sampled every 1/10th of the time! Scenarios! View count Reference: https://github.com/etsy/statsd/blob/master/docs/metric_types.md
  7. 7. Metric Types Gauge [key]:[value]|g! sample.gauge:75|g! If the gauge is not updated at the next flush, it will send the previous value.! Scenarios! Resource number
  8. 8. Metric Types Set [key]:[value]|s! sapmle.set:4219|s! Counting unique occurrences of events between flushes, using a Set to store all occurring events.! Scenarios! Unique user count
  9. 9. Metric Types Timing [key]:[value]|ms! sample.timer:10000|ms! Scenarios! To calculate the difference time! Response time calculation
  10. 10. Demo
  11. 11. StatsD Server Install Node before using npm! Install StatsD! npm install -g statsd! Run StatsD! node stats.js config.js
  12. 12. config.js! Statsd UDP port: 8125! Backends: [ "./backends/ console", "./backends/ graphite" ] { graphitePort: 2003, graphiteHost: "graphite.hostname", address: "127.0.0.1", port: 8125, mgmt_address: "127.0.0.1", mgmt_port: 8126, backends: [ "./backends/ graphite" ], graphite: { legacyNamespace: false, globalPrefix: "stats", prefixCounter: "counters", prefixTimer: "timers", prefixGauge: "gauges", prefixSet: "sets" } } StatsD Server
  13. 13. StatsD Clients Node client! https://github.com/msiebuhr/node-statsd- client! Java client! https://github.com/tim-group/java-statsd- client Reference: https://github.com/etsy/statsd/wiki
  14. 14. Node Client var SDC = require(‘statsd-client');! Increment! sdc.increment("sample.counter");! sdc.increment("sample.mycounter", 10);! Gauge! sdc.gauge("sample.gauge", randomInteger(100));
  15. 15. Node Client Set! sdc.set("sapmle.set", randomInteger(10000));! Timer! timer = new Date();! sdc.timing("sample.timer", timer);
  16. 16. Java Client public class Foo { private static final StatsDClient statsd = new NonBlockingStatsDClient("my.prefix", "statsd-­‐host", 8125); ! public static final void main(String[] args) { statsd.incrementCounter("bar"); statsd.recordGaugeValue("baz", 100); statsd.recordExecutionTime("bag", 25); statsd.recordSetEvent("qux", "one"); }
  17. 17. CollectD vs StatsD? CollectD: Collect system data! StatsD: Collect application data
  18. 18. Next?
  19. 19. Further Items StatsD Cluster Proxy! Refactor 3DS FrontServer! Collect response time during component communication! Collect data from GPS (Windows)

×