Created
August 18, 2012 17:18
-
-
Save JohnMurray/3388516 to your computer and use it in GitHub Desktop.
Fnord Metric and C# Blog Post (http://goo.gl/F8MH5) -- Part 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event(:login) { incr(:logins_per_hour) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gauge :logins_per_hour, | |
:tick => 1.hour.to_i, | |
:title => 'Logins per Hour' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FnordMetric.namespace :my_first_fnord do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install fnordmetric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "_type": "login" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby fnord.rb run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment