Skip to content

Instantly share code, notes, and snippets.

@JohnMurray
Created August 18, 2012 17:18
Show Gist options
  • Save JohnMurray/3388516 to your computer and use it in GitHub Desktop.
Save JohnMurray/3388516 to your computer and use it in GitHub Desktop.
Fnord Metric and C# Blog Post (http://goo.gl/F8MH5) -- Part 1
## fnord.rb
require 'fnordmetric'
FnordMetric.namespace :my_first_fnord do
# numeric gauge, shown on a per-hour total
gauge :logins_per_hour,
:tick => 1.hour.to_i,
:title => 'Logins per Hour'
event(:login) { incr(:logins_per_hour) }
widget 'Web Logins', {
:title => 'Web App Logins Per Hour',
:type => :timeline,
:gauges => :logins_per_hour,
:include_current => true,
:autoupdate => 2 #update graph every 2 seconds
}
end
FnordMetric.standalone
## fnord.rb
# fnord namespace definition (as shown previously)
FnordMetric.server_configuration = {
# point to external redis on non-standard port
redis_url: 'redis://10.1.0.38:6380',
# prefix on events pushed to redis
redis_prefix: 'mavia-metrics',
# port on which to accept event-pushes (we're not using this)
inbound_stream: ['0.0.0.0', '1339'],
# port to run web interface
web_interface: ['0.0.0.0', '80'],
# worker "process" to watch redis (we want this)
start_worker: true,
# make the program chatty so we know how it's feeling
print_stats: 3,
# events not processed after 2 minutes are dropped
event_queue_ttl: 120,
# event data is kept for one month
event_data_ttl: 3600*24*30,
# session data is kept for one month
:session_data_ttl: 3600*24*30
}
FnordMetric.standalone
event(:login) { incr(:logins_per_hour) }
gauge :logins_per_hour,
:tick => 1.hour.to_i,
:title => 'Logins per Hour'
FnordMetric.namespace :my_first_fnord do
widget 'Web Logins', {
:title => 'Web App Logins Per Hour',
:type => :timeline,
:gauges => :logins_per_hour,
:include_current => true,
:autoupdate => 2 #update graph every 2 seconds
}
gem install fnordmetric
{ "_type": "login" }
using(var client = new RedisClient("linux.mysite.com:6379"))
{
String guid = Guid.NewGuid().ToString("N");
String fnordId = String.Format("fnordmetric-event-{0}", guid)
client.Set(fnordId, "{\"_type\": \"login\"}");
client.Expire(fnordId, new TimeSpan(0, 0, 60));
client.LPush("fnordmetric-queue", guid);
}
ruby fnord.rb run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment