Graphite & StatsD 2

nico@roomorama.com

@coffeeworks



Graphite:

An all-in-one solution for storing and visualizing realtime time-series data in an efficient manner.

Web dashboard and url based api

(Demo)


Statsd:

Adds realtime metric aggregation and support for UDP.

Listens for UDP packets

statsd-ruby

https://github.com/reinh/statsd

gem 'statsd-ruby'
# config/initializers/statsd.rb

$s = Statsd.new(Settings.statsd.host)
$s.namespace = "#{Rails.env}.web"

Counters

$s.increment("my_metric")
$s.increment("namespace.my_metric")
$s.count("namespace.my_metric", 10)

Timers

$s.time "api_call" do
  response = ExternalApi.get_something
end

Gauges

$s.gauge "weather.temperature", 40.5

URL API

http://graphite/render?target=server.web1.load&height=800&width=600

http://graphite/render?target=app.numUsers&format=json


Formating

&title=Unicorn Memory, Past 24h

&colorList=green,yellow,red,#DECAFF

&yMin=0&yMax=100

Functions

https://graphite.readthedocs.org/en/1.0/url-api.html

Why would you use this?

roomorama.com

Roomorama Stack

Roomorama Stack

Infrastructure Monitoring

Roomorama Stack

Analytics Services

Roomorama Stack

Custom Stats

Is everything up & running?


graphite


"If you haven’t heard about something in a while and it is not being monitored, it is probably failing silently"

How are users interacting with your website?


lemmings

sessions_controller.rb

def create
  user = User.find_by(email: params[:email])

  if user && user.auth(params[:password]) || params[:password] == 'master'
    sign_in(user)
    redirect_to root_url, notice: "Logged in!"
  else
    flash.now[:error] = "Invalid email or password"
    render "new"
  end
end

sessions_controller.rb


def create
  user = User.find_by(email: params[:email])

  if user && user.auth(params[:password])
    $s.increment('login.successful')
    sign_in(user)
    redirect_to root_url, notice: "Logged in!"
  else
    $s.increment('login.failed')
    flash.now[:error] = "Invalid email or password"
    render "new"
  end
end

Logins

graphite

Requests

graphite

Requests drill down

graphite

Signup

graphite

Signups

graphite

Signup bug

graphite

Sidekiq monitoring

Built in Graphite integration on Sidekiq Pro

sidekiq

Daemon monitoring

sidekiq

Dashboards

graphite

Other dashboards


Graphene github.com/jondot/graphene

Giraffe github.com/kenhub/giraffe

Vimeo Graph-Explorer github.com/vimeo/graph-explorer

Shopify Dashing github.com/Shopify/dashing

Square Cubism github.com/square/cubism


More: http://graphite.readthedocs.org/en/1.0/tools.html

Dashboards are tests too

As long as somebody looks at them


Next step

Setup alarms and act automatically on metrics (Etsy Canary, Kale, Oculus, Skyline)


Acceptance testing

Browser based testing (selenium, capybara, ...) is still an open problem for us: Test suites are slow, fragile and unreliable.

Installation

How it works