Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Graphite & StatsD Workshop

ProdOps
October 01, 2013

Graphite & StatsD Workshop

Graphite & StatsD workshop for DevopsDays Tel Aviv 2013

Installation of graphite and statsd. General terminology about monitoring and its importance. Dashboards galore! And understanding StatsD - all in one.

ProdOps

October 01, 2013
Tweet

More Decks by ProdOps

Other Decks in Technology

Transcript

  1. Installation • Prerequisuites ◦ VirtualBox ◦ Vagrant • Packages ◦

    nodejs ◦ collectd ◦ python virtualenv ◦ libcairo dev headers bit.ly/dodtlv2013-graphite-code
  2. (more) Installation • source / git ◦ graphite.wikidot.com/installation • chef

    ◦ community.opscode.com/cookbooks/graphite • fabric ◦ github.com/gingerlime/graphite-fabric • puppet ◦ forge.puppetlabs.com/modules?q=graphite
  3. graphite.readthedocs.org/en/latest/feeding-carbon.html echo "local.random.diceroll 4 `date +%s`" | \ nc graphite.your.org

    2003; • carbon-cache ◦ accept metrics, write to disk • carbon-relay ◦ replication, sharding • carbon-aggregator ◦ buffer metrics, aggregate, send to carbon-cache Carbon
  4. graphite.readthedocs.org/en/latest/feeding-carbon.html bash echo "local.random.diceroll 4 $(date +%s)" | \ nc

    -u graphite.your.org 2003 Python import socket sock = socket.socket(socket.AF_INET, socket. SOCK_DGRAM)) sock.connect( ('127.0.0.1', 2003) ) sock.sendall( 'foo.bar.baz 42 %d\n' % int(time.time()) ) sock.close() Send (app) metrics to Carbon
  5. • collectd >= 5.1.x LoadPlugin "write_graphite" <Plugin "write_graphite"> <Carbon> Host

    "localhost" Port "2003" </Carbon> </Plugin> Tools sending data to Carbon
  6. • Sensu # /etc/sensu/conf.d/graphite_tcp.json { "graphite": { "server":"graphite.example.com", "port":"2003" }

    } # /etc/sensu/conf.d/handler_graphite.json { "handlers": { "graphite": { "type": "pipe", "command": "/etc/sensu/handlers/graphite_tcp.rb" } } } Tools sending data to Carbon
  7. Whisper • Round-robin (based on rrd concepts) ◦ Fixed size

    ◦ New data pushes older data away • Multiple precisions • Everything is a float • { timestamp: value }
  8. Schemas for Storage 1 year of minutely data = 6mb

    per metric • more metrics → i/o & space • how long is your data useful for? • what is the precision you really need?
  9. storage-schemas.conf cat <<-EOF > $graphite_root/conf/storage-schemas.conf [default_1min_for_1day] pattern = .* retentions

    = 60s:1d [collectd] pattern = ^collectd\. retentions = 10s:30d [stats] priority = 110 pattern = ^stats.* retentions = 10s:6h,1m:7d,10m:1y EOF
  10. [min] pattern = \.lower$ xFilesFactor = 0.5 aggregationMethod = min

    [sum] pattern = \.sum$ xFilesFactor = 0.5 aggregationMethod = sum [default_average] pattern = .* xFilesFactor = 0.6 aggregationMethod = average storage-aggregation.conf
  11. Notice the default xFilesFactor value < 1 xFilesFactor is the

    ratio of precision data points your archive must contain to be rolled up accurately. More than half nulls would aggregate to a null archive. xFilesFactor
  12. Whisper Gotchas Avoid this - [default] pattern = .* retentions

    = 1s:1h, 10s:6h, 60s:1w, 5m:30d, 1h:1y Keep xFilesFactor >= 0.5 to avoid excess I/O Fetch returns data from single archive (only!)
  13. Aggregation • Averaging ◦ great for trending ◦ applies to

    most data ◦ calculate aggregate sum if number of samples is known • Types: ◦ Average, Sum, Min, Max, Latest
  14. Per Second rates statsd / collectd (StoreRates true) / …

    • Store as averages • Multiple by precision on query • scale(<metric>, 60)
  15. Dashboards / Tools codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/ • Etsy’s StatsD ◦ github.com/etsy/statsd •

    Etsy’s check_graphite_data ◦ github.com/etsy/nagios_tools • Etsy’s Dashboard ◦ github.com/etsy/dashboard
  16. • GitHub OctoStatus (iOS app) ◦ not open source, but

    some source at - ◦ speakerdeck.com/wfarr/graphs-for-the-fucking-win • GitHub Descartes ◦ github.com/obfuscurity/descartes • Tasseo ◦ github.com/obfuscurity/tasseo Jason Dixon - obfuscurity.com Dashboards / Tools
  17. dashboarddude.com/blog/2013/01/23/dashboards-for-graphite • Cubism.js square.github.io/cubism • Graphene jondot.github.io/graphene • Giraffe github.com/kenhub/giraffe

    • Seyren github.com/scobal/seyren • Graphitus github.com/erezmazor/graphitus • Graphiti github.com/paperlesspost/graphiti • GDash github.com/ripienaar/gdash • Dashing shopify.github.io/dashing • Graph Explorer vimeo.github.io/graph-explorer More Dashboards
  18. StatsD types statsd.rtfd.org/en/latest/types.html • Counters - statsd.incr('some.event') • Timers -

    statsd.timing('slept',10000) # int millis • Gauges - statsd.gauge('foo', 70)
  19. StatsD Backends ◦ amqp ◦ ganglia ◦ librato ◦ socket.io

    ◦ statsd ◦ mongo ◦ datadog ◦ monitis ◦ zabbix ◦ mysql