Skip to content

Instantly share code, notes, and snippets.

@joerodriguez
Created March 31, 2015 05:05
Show Gist options
  • Save joerodriguez/8ca1bdf2b6161a06b219 to your computer and use it in GitHub Desktop.
Save joerodriguez/8ca1bdf2b6161a06b219 to your computer and use it in GitHub Desktop.
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
@joerodriguez
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment