Created
March 31, 2015 05:05
-
-
Save joerodriguez/8ca1bdf2b6161a06b219 to your computer and use it in GitHub Desktop.
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
events = { | |
processed: 99, | |
open: 32, | |
click: 12, | |
spam: 1 | |
} | |
subaccounts = [ | |
"8a9dhf", | |
"3984hi", | |
"ifjejf", | |
"098ffd" | |
] | |
email_addresses = [ | |
"joe@aol.com", | |
"joe@gmail.com", | |
"joe@hotmail.com", | |
"joe@yahoo.com" | |
] | |
email_ids = [ | |
"asdfsdf", | |
"lgfngbg", | |
"kjdf8ff", | |
"io904kd", | |
"oj984nf", | |
"8jfilks", | |
"dksidk4" | |
] | |
require 'influxdb' | |
influxdb = InfluxDB::Client.new "email_events", :username => "root", :password => "root" | |
loop do | |
events.each do |event, chance| | |
next if rand(101) > chance | |
data = { | |
subaccount: subaccounts.sample, | |
email_id: email_ids.sample, | |
recipient: email_addresses.sample, | |
type: event | |
} | |
name = "subgroup.#{data[:subaccount]}" | |
influxdb.write_point(name, data, false, "s") | |
end | |
end | |
# select count(type) from /^subgroup.*/ group by time(1m), type into stats.1m.for.:series_name | |
# select count(type) from /^subgroup.*/ group by time(1h), type into stats.1h.for.:series_name | |
# select count(type) from /^subgroup.*/ group by time(1m), type, email_id into stats.1m.for.email.[email_id].for.:series_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a nice write up on retention policies
http://www.kibinlabs.com/influxdb-continuous-queries-and-retention-policies/