19
StatsD Introduction Rick chang

Statsd introduction

Embed Size (px)

Citation preview

Page 1: Statsd introduction

StatsD IntroductionRick chang

Page 2: Statsd introduction

Agenda

History!

Architecture!

Concept!

Demo!

Implementation

Page 3: Statsd introduction

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

Page 4: Statsd introduction

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/

Page 5: Statsd introduction

Architecture

Your App send data to StatsD by UDP port 8125!

StatsD send data to Carbon by TCP port 2003

Page 6: Statsd introduction

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|[email protected]!

sent sampled every 1/10th of the time!

Scenarios!

View count

Reference: https://github.com/etsy/statsd/blob/master/docs/metric_types.md

Page 7: Statsd introduction

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

Page 8: Statsd introduction

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

Page 9: Statsd introduction

Metric Types

Timing [key]:[value]|ms!

sample.timer:10000|ms!

Scenarios!

To calculate the difference time!

Response time calculation

Page 10: Statsd introduction

Demo

Page 11: Statsd introduction

StatsD Server

Install Node before using npm!

Install StatsD!

npm install -g statsd!

Run StatsD!

node stats.js config.js

Page 12: Statsd introduction

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

Page 13: Statsd introduction

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

Page 14: Statsd introduction

Node Client

var SDC = require(‘statsd-client');!

Increment!

sdc.increment("sample.counter");!

sdc.increment("sample.mycounter", 10);!

Gauge!

sdc.gauge("sample.gauge", randomInteger(100));

Page 15: Statsd introduction

Node Client

Set!

sdc.set("sapmle.set", randomInteger(10000));!

Timer!

timer = new Date();!

sdc.timing("sample.timer", timer);

Page 16: Statsd introduction

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");      }

Page 17: Statsd introduction

CollectD vs StatsD?

CollectD: Collect system data!

StatsD: Collect application data

Page 18: Statsd introduction

Next?

Page 19: Statsd introduction

Further Items

StatsD Cluster Proxy!

Refactor 3DS FrontServer!

Collect response time during component communication!

Collect data from GPS (Windows)