Commit efe6e6ba authored by Paul Asmuth's avatar Paul Asmuth
Browse files

full_example

parent af9b7369
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ ROADMAP

  > Core: Backend
    - split up fnordmetric.namespace block into multiple files
    - special events (incr, observe etc)
    - caching
    - use rack websocket instead of em websocket
    - gauge garbage-collection
+71 −46
Original line number Diff line number Diff line
@@ -5,75 +5,100 @@ FnordMetric.options = {
  :event_queue_ttl  => 10, # all data that isn't processed within 10s is discarded to prevent memory overruns
  :event_data_ttl   => 10,
  :session_data_ttl => 1,  # we don't care about session data for now
  :redis_prefix => "fnordmetric-dawanda" 
  :redis_prefix => "fnordmetric" 
}

FnordMetric.namespace :ulm do

  gauge :skip_votes, :tick => 1.day.to_i, :title => "Skip-Votes"
  gauge :yes_votes, :tick => 1.day.to_i, :title => "Yes-Votes"
  gauge :maybe_votes, :tick => 1.day.to_i, :title => "Maybe-Votes"

  gauge :messages_sent, :tick => 1.day.to_i, :title => "Messages (sent)"
  gauge :messages_read, :tick => 1.day.to_i, :title => "Messages (read)"
  gauge :winks_sent, :tick => 1.day.to_i, :title => "Winks sent"

FnordMetric.namespace :myapp do

  timeseries_gauge :gross_search_volume,
    :tick => 30.seconds,
    :group => "Search",
    :title => "Gross Search Volume",
    :key_nouns => ["Search", "Searches"],
    :series => [:without_filter, :with_filter]
    #:enable_punchcard => true,
    #:enable_realtime => true

  timeseries_gauge :number_of_signups,
    :title => "Number of Signups",
    :series => [:signup_via_twitter, :signup_via_openid],
    :resolution => 30.seconds

  widget 'Overview', {
    :title => "Yes/No/Skip-Votes",

  distribution_gauge :user_age_distribution,
    :title => "User Age Distribution",
    :resolution => 30.seconds


  toplist_gauge :popular_keywords,
    :title => "Popular Keywords",
    :resolution => 30.seconds
  

  gauge :events_per_hour, :tick => 1.hour
  gauge :events_per_second, :tick => 1.second
  gauge :events_per_minute, :tick => 1.minute

  event :"*" do
    incr :events_per_hour
    incr :events_per_minute
    incr :events_per_second
  end

  widget 'TechStats', {
    :title => "Events per Minute",
    :type => :timeline,
    :gauges => [:skip_votes, :yes_votes, :maybe_votes]
    :width => 100,
    :gauges => :events_per_minute,
    :include_current => true,
    :autoupdate => 30
  }

  widget 'Overview', {
    :title => "Yes/No/Skip Numbers",
    :type => :numbers,
    :gauges => [:skip_votes, :yes_votes, :maybe_votes]
  widget 'TechStats', {
    :title => "Events per Hour",
    :type => :timeline,
    :width => 50,
    :gauges => :events_per_hour,
    :include_current => true,
    :autoupdate => 30
  }

  widget 'Overview', {
    :title => "Messages sent/read",

  widget 'TechStats', {
    :title => "Events/Second",
    :type => :timeline,
    :gauges => [:messages_sent, :messages_read, :winks_sent]
    :width => 50,
    :gauges => :events_per_second,
    :include_current => true,
    :plot_style => :areaspline,
    :autoupdate => 1
  }

  widget 'Overview', {
    :title => "Messages sent+read/Winks Numbers",
  widget 'TechStats', {
    :title => "Events Numbers",
    :type => :numbers,
    :gauges => [:messages_sent, :messages_read, :winks_sent]
    :width => 100,
    :gauges => [:events_per_second, :events_per_minute, :events_per_hour],
    :offsets => [1,3,5,10],
    :autoupdate => 1
  }

  widget 'Overview', {
    :title => "User-Activity",
    :type => :timeline,
    :width => 67,
    :autoupdate => 30,
    :gauges => [:skip_votes, :yes_votes, :maybe_votes]
  }
end


def start_example_data_generator

  api = FnordMetric::API.new
  Thread.new do
    loop do      
      api.event(:_type => :unicorn_seen)
      sleep rand(10)/10.to_f
    end
  end

FnordMetric.options = {
  :print_stats => 3
}
end

FnordMetric::Logger.new(
  :file => '/home/paul/fnordmetric.log',
  :channels => ["dawanda-firehose"]
)
start_example_data_generator

FnordMetric::Web.new(:port => 4242)

FnordMetric::Acceptor.new(:protocol => :tcp, :port => 2323)

FnordMetric::Worker.new
FnordMetric.run