all_seeing_eye 0.0.20 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +36 -20
- data/VERSION +1 -1
- data/all_seeing_eye.gemspec +3 -3
- data/lib/all_seeing_eye/server/views/field.erb +1 -1
- data/lib/all_seeing_eye/server/views/layout.erb +3 -1
- data/lib/all_seeing_eye/server/views/left.erb +6 -5
- data/lib/all_seeing_eye/server.rb +57 -45
- data/lib/{all_seeing_eye/generators → generators/all_seeing_eye}/all_seeing_eye_generator.rb +1 -1
- data/lib/{all_seeing_eye/generators → generators/all_seeing_eye/templates}/all_seeing_eye.yml +0 -0
- metadata +5 -5
data/README.markdown
CHANGED
@@ -28,20 +28,22 @@ we can't just start collecting it again. Combined with some code to store arbitr
|
|
28
28
|
So, AllSeeingEye was born out of our need to track incoming requests accurately, quickly, and in a way that is easily
|
29
29
|
displayable to our business users.
|
30
30
|
|
31
|
+
...but this early version still has a few pain points I'm working out. So some requests are slower than I'd like. But everything will be fast soon enough!
|
32
|
+
|
31
33
|
## Installation
|
32
34
|
|
33
35
|
Get Redis via the amazing Homebrew: `brew install redis`
|
34
36
|
|
35
|
-
Add AllSeeingEye to your project's Gemfile: `gem '
|
37
|
+
Add AllSeeingEye to your project's Gemfile: `gem 'all_seeing_eye'`
|
36
38
|
|
37
39
|
Install it with Bundler: `bundle install`
|
38
40
|
|
39
41
|
## Setup
|
40
42
|
|
41
|
-
|
43
|
+
bundle exec ruby script/generate all_seeing_eye
|
42
44
|
|
43
45
|
This puts the AllSeeingEye config file at config/all\_seeing\_eye.yml. The file is annotated with all the information you
|
44
|
-
need to get started, but some quick
|
46
|
+
need to get started, but some quick explanations:
|
45
47
|
|
46
48
|
### Timeout
|
47
49
|
AllSeeingEye's data collection is wrapped by a timeout to ensure speediness. I keep this value at 30 milliseconds (0.03), but
|
@@ -61,13 +63,13 @@ shared between them. I only use one right now (I call it 'request'), but if you
|
|
61
63
|
|
62
64
|
Each model definition should be structured like this:
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
model_name:
|
67
|
+
first_field_name:
|
68
|
+
object: object_name
|
69
|
+
method: .method_name
|
70
|
+
second_field_name:
|
71
|
+
object: hash
|
72
|
+
method: "['key']"
|
71
73
|
|
72
74
|
Model names and field names are completely arbitrary, and I try to humanize them as best as I can.
|
73
75
|
|
@@ -80,28 +82,42 @@ and/or bad method... so try not to do that.
|
|
80
82
|
As a helpful hint, recording "request\_uri" isn't nearly as helpful as you might think. Try to save requests without any params
|
81
83
|
and without a leading slash by defining a method in ApplicationController instead:
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
protected
|
86
|
+
def clean_request
|
87
|
+
request.request_uri.split('?').first[1..-1]
|
88
|
+
end
|
87
89
|
|
88
90
|
Then, in your all\_seeing\_eye.yml:
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
request:
|
93
|
+
uri:
|
94
|
+
object: controller
|
95
|
+
method: .clean_request
|
94
96
|
|
95
97
|
## Running
|
96
98
|
|
97
|
-
When your Rails application starts, you should see each request contain
|
99
|
+
When your Rails application starts, you should see each request contain `+++ Request watched by AllSeeingEye`. That means
|
98
100
|
AllSeeingEye is running successfully. Good job!
|
99
101
|
|
100
102
|
Starting the server is simple. Just type `all-seeing-eye` from the commandline and Sinatra should start automatically.
|
101
103
|
|
104
|
+
Using the web interface is fairly straightforward; the only bit that might need some explanation is searching, which is
|
105
|
+
kinda nifty.
|
106
|
+
|
107
|
+
### Searching
|
108
|
+
|
109
|
+
You can use the text field in the upper-right to search. Right now, AllSeeingEye accepts queries in one of two formats:
|
110
|
+
|
111
|
+
1. One time in the past followed by another time in the past, separated by "to". AllSeeingEye uses Chronic for natural
|
112
|
+
language parsing on times, so you can use "yesterday to now", "last friday to yesterday", "last christmas to last easter"
|
113
|
+
and whatever other query formats Chronic supports.
|
114
|
+
2. A field and a value, separated by a colon. So "ip:127.0.0.1" will show all results for that IP address,
|
115
|
+
"account:josh@joshsymonds.com" to find an account by a specific email, and so on. This will automatically try to find
|
116
|
+
the correct model that you're searching for as well, which is helpful.
|
117
|
+
|
102
118
|
## Extras
|
103
119
|
|
104
|
-
I included the
|
120
|
+
I included the nginx config we use for AllSeeingEye as a small bonus. It's in examples/all\_seeing\_eye-nginx.conf.
|
105
121
|
|
106
122
|
## Contributing to AllSeeingEye
|
107
123
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/all_seeing_eye.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{all_seeing_eye}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Josh Symonds"]
|
@@ -30,8 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
"examples/all_seeing_eye-nginx.conf",
|
31
31
|
"init.rb",
|
32
32
|
"lib/all_seeing_eye.rb",
|
33
|
-
"lib/all_seeing_eye/generators/all_seeing_eye.yml",
|
34
|
-
"lib/all_seeing_eye/generators/all_seeing_eye_generator.rb",
|
35
33
|
"lib/all_seeing_eye/integrations/rails2.rb",
|
36
34
|
"lib/all_seeing_eye/model.rb",
|
37
35
|
"lib/all_seeing_eye/server.rb",
|
@@ -46,6 +44,8 @@ Gem::Specification.new do |s|
|
|
46
44
|
"lib/all_seeing_eye/server/views/layout.erb",
|
47
45
|
"lib/all_seeing_eye/server/views/left.erb",
|
48
46
|
"lib/all_seeing_eye/server/views/total.erb",
|
47
|
+
"lib/generators/all_seeing_eye/all_seeing_eye_generator.rb",
|
48
|
+
"lib/generators/all_seeing_eye/templates/all_seeing_eye.yml",
|
49
49
|
"test/base_test.rb",
|
50
50
|
"test/fixtures/all_seeing_eye.yml",
|
51
51
|
"test/fixtures/redis-test.conf",
|
@@ -78,7 +78,7 @@
|
|
78
78
|
|
79
79
|
$("#graph").bind("plotclick", function (event, pos, item) {
|
80
80
|
if (item) {
|
81
|
-
window.location = '<%= u "
|
81
|
+
window.location = '<%= u "#{@model.model_name}/#{CGI::escape(@field)}/" %>' + encodeURIComponent(ids[item.dataIndex])
|
82
82
|
}
|
83
83
|
});
|
84
84
|
</script>
|
@@ -1,19 +1,20 @@
|
|
1
|
+
<% tabs = @model.field_keys %>
|
1
2
|
<% if @field %>
|
2
3
|
<% if @id %>
|
3
4
|
<div id='left'>
|
4
5
|
<ul>
|
5
|
-
<li class=<%= current_page.split(CGI.escape(@id))[1] ? '' : 'current' %>><a href="<%= u "
|
6
|
+
<li class=<%= current_page.split(CGI.escape(@id))[1] ? '' : 'current' %>><a href="<%= u "#{@model.model_name}/#{@field}/#{CGI.escape(@id)} " %>">Total</a></li>
|
6
7
|
<% (tabs - [@field]).each do |t| %>
|
7
|
-
<%= tab t, "
|
8
|
+
<%= tab t, "#{@model.model_name}/#{@field}/#{CGI.escape(@id)}" %>
|
8
9
|
<% end %>
|
9
10
|
</ul>
|
10
11
|
</div>
|
11
12
|
<% elsif @query%>
|
12
13
|
<div id='left'>
|
13
14
|
<ul>
|
14
|
-
<li class=<%= current_page.split(CGI.escape(@query))[1] ? '' : 'current' %>><a href="<%= u "search/#{CGI.escape(@query) }" %>"}>Total</a></li>
|
15
|
+
<li class=<%= current_page.split(CGI.escape(@query))[1] ? '' : 'current' %>><a href="<%= u "search/#{@model.model_name}/#{CGI.escape(@query) }" %>"}>Total</a></li>
|
15
16
|
<% tabs.each do |t| %>
|
16
|
-
<%= tab t, "search/#{CGI.escape(@query)}" %>
|
17
|
+
<%= tab t, "search/#{@model.model_name}/#{CGI.escape(@query)}" %>
|
17
18
|
<% end %>
|
18
19
|
</ul>
|
19
20
|
</div>
|
@@ -21,7 +22,7 @@
|
|
21
22
|
<div id='left'>
|
22
23
|
<ul>
|
23
24
|
<% (tabs).each do |t| %>
|
24
|
-
<%= tab t,
|
25
|
+
<%= tab t, @model.model_name %>
|
25
26
|
<% end %>
|
26
27
|
</ul>
|
27
28
|
</div>
|
@@ -80,64 +80,76 @@ class AllSeeingEye
|
|
80
80
|
end
|
81
81
|
|
82
82
|
get '/search' do
|
83
|
-
|
83
|
+
AllSeeingEye.configuration[:models].each do |m|
|
84
|
+
results = m.search(params[:query])
|
85
|
+
if !results.nil? && !results.empty?
|
86
|
+
redirect url_path("/search/#{m.model_name}/#{CGI::escape(params[:query])}")
|
87
|
+
break
|
88
|
+
end
|
89
|
+
end
|
90
|
+
show :total
|
84
91
|
end
|
85
92
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
get "/fields/#{field}" do
|
92
|
-
@page = params[:page].blank? ? 1 : params[:page].to_i
|
93
|
-
@field = field
|
94
|
-
@count = AllSeeingEye::Request.count
|
95
|
-
@requests = AllSeeingEye::Request.list_by_field(@field, :page => @page)
|
96
|
-
show :field
|
97
|
-
end
|
98
|
-
|
99
|
-
get %r{/search/(.*?)/#{field}$} do
|
100
|
-
@page = params[:page].blank? ? 1 : params[:page].to_i
|
101
|
-
@field = field
|
102
|
-
@query = params[:captures].first
|
103
|
-
@requests = AllSeeingEye::Request.search(@query)
|
104
|
-
counts = Hash.new(0)
|
105
|
-
@requests.each {|r| next if r.send(@field.to_sym).nil?; counts[r.send(@field.to_sym)] += 1}
|
106
|
-
@requests = counts.sort {|a, b| b.last <=> a.last}
|
107
|
-
show :field
|
93
|
+
AllSeeingEye.configuration[:models].each do |model|
|
94
|
+
|
95
|
+
get "/#{model.model_name}" do
|
96
|
+
@model = model
|
97
|
+
redirect url_path("/#{model.model_name}/#{model.field_keys.first}")
|
108
98
|
end
|
109
99
|
|
110
|
-
|
111
|
-
get
|
100
|
+
AllSeeingEye::Request.field_keys.each do |field|
|
101
|
+
get "/#{model.model_name}/#{field}" do
|
102
|
+
@model = model
|
112
103
|
@page = params[:page].blank? ? 1 : params[:page].to_i
|
113
104
|
@field = field
|
114
|
-
@
|
115
|
-
@
|
116
|
-
|
105
|
+
@count = model.count
|
106
|
+
@requests = model.list_by_field(@field, :page => @page)
|
107
|
+
show :field
|
108
|
+
end
|
109
|
+
|
110
|
+
get %r{/search/#{model.model_name}/(.*?)/#{field}$} do
|
111
|
+
@model = model
|
112
|
+
@page = params[:page].blank? ? 1 : params[:page].to_i
|
113
|
+
@field = field
|
114
|
+
@query = params[:captures].first
|
115
|
+
@requests = model.search(@query)
|
117
116
|
counts = Hash.new(0)
|
118
|
-
@requests.each {|r| next if r.send(@
|
117
|
+
@requests.each {|r| next if r.send(@field.to_sym).nil?; counts[r.send(@field.to_sym)] += 1}
|
119
118
|
@requests = counts.sort {|a, b| b.last <=> a.last}
|
120
119
|
show :field
|
121
120
|
end
|
122
|
-
|
121
|
+
|
122
|
+
(AllSeeingEye::Request.field_keys - [field]).each do |f|
|
123
|
+
get %r{/#{model.model_name}/#{field}/(.*?)/#{f}$} do
|
124
|
+
@model = model
|
125
|
+
@page = params[:page].blank? ? 1 : params[:page].to_i
|
126
|
+
@field = field
|
127
|
+
@id = params[:captures].first
|
128
|
+
@view = f
|
129
|
+
@requests = model.find_by_field(@field, :value => @id)
|
130
|
+
counts = Hash.new(0)
|
131
|
+
@requests.each {|r| next if r.send(@view.to_sym).nil?; counts[r.send(@view.to_sym)] += 1}
|
132
|
+
@requests = counts.sort {|a, b| b.last <=> a.last}
|
133
|
+
show :field
|
134
|
+
end
|
135
|
+
end
|
123
136
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
137
|
+
get %r{/#{model.model_name}/#{field}/(.*)$} do
|
138
|
+
@model = model
|
139
|
+
@field = field
|
140
|
+
@id = params[:captures].first
|
141
|
+
@counts = model.list_by_field(@field, :value => @id)
|
142
|
+
show :total
|
143
|
+
end
|
129
144
|
end
|
130
|
-
end
|
131
145
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
def tabs
|
140
|
-
@tabs ||= AllSeeingEye::Request.field_keys
|
146
|
+
get %r{/search/#{model.model_name}/(.*?)$} do
|
147
|
+
@model = model
|
148
|
+
@field = 'total'
|
149
|
+
@query = params[:captures].first
|
150
|
+
@counts = model.search(@query, :count => true)
|
151
|
+
show :total
|
152
|
+
end
|
141
153
|
end
|
142
154
|
end
|
143
155
|
end
|
data/lib/{all_seeing_eye/generators → generators/all_seeing_eye/templates}/all_seeing_eye.yml
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: all_seeing_eye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.20
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Symonds
|
@@ -185,8 +185,6 @@ files:
|
|
185
185
|
- examples/all_seeing_eye-nginx.conf
|
186
186
|
- init.rb
|
187
187
|
- lib/all_seeing_eye.rb
|
188
|
-
- lib/all_seeing_eye/generators/all_seeing_eye.yml
|
189
|
-
- lib/all_seeing_eye/generators/all_seeing_eye_generator.rb
|
190
188
|
- lib/all_seeing_eye/integrations/rails2.rb
|
191
189
|
- lib/all_seeing_eye/model.rb
|
192
190
|
- lib/all_seeing_eye/server.rb
|
@@ -201,6 +199,8 @@ files:
|
|
201
199
|
- lib/all_seeing_eye/server/views/layout.erb
|
202
200
|
- lib/all_seeing_eye/server/views/left.erb
|
203
201
|
- lib/all_seeing_eye/server/views/total.erb
|
202
|
+
- lib/generators/all_seeing_eye/all_seeing_eye_generator.rb
|
203
|
+
- lib/generators/all_seeing_eye/templates/all_seeing_eye.yml
|
204
204
|
- test/base_test.rb
|
205
205
|
- test/fixtures/all_seeing_eye.yml
|
206
206
|
- test/fixtures/redis-test.conf
|