fluent-plugin-flowcounter 0.1.3 → 0.1.4
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.rdoc +10 -0
- data/VERSION +1 -1
- data/fluent-plugin-flowcounter.gemspec +3 -3
- data/lib/fluent/plugin/out_flowcounter.rb +13 -4
- data/test/plugin/test_out_flowcounter.rb +40 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -59,6 +59,16 @@ Counts from field 'message', per hour, aggregates all tags, output with tag 'flu
|
|
59
59
|
# output configurations where to send count results
|
60
60
|
</match>
|
61
61
|
|
62
|
+
To count with all fields in messages, specify 'count_keys *'.
|
63
|
+
|
64
|
+
<match target.**>
|
65
|
+
type flowcounter
|
66
|
+
count_keys *
|
67
|
+
unit hour
|
68
|
+
aggregate all
|
69
|
+
tag fluentd.traffic
|
70
|
+
</match>
|
71
|
+
|
62
72
|
== TODO
|
63
73
|
|
64
74
|
- consider what to do next
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fluent-plugin-flowcounter"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["TAGOMORI Satoshi"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-24"
|
13
13
|
s.description = "Plugin to counts messages/bytes that matches, per minutes/hours/days"
|
14
14
|
s.email = "tagomoris@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
]
|
33
33
|
s.homepage = "http://github.com/tagomoris/fluent-plugin-flowcounter"
|
34
34
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = "1.8.
|
35
|
+
s.rubygems_version = "1.8.21"
|
36
36
|
s.summary = "Plugin to counts messages/bytes that matches, per minutes/hours/days"
|
37
37
|
s.test_files = ["test/helper.rb", "test/plugin/test_out_flowcounter.rb"]
|
38
38
|
|
@@ -9,6 +9,7 @@ class Fluent::FlowCounterOutput < Fluent::Output
|
|
9
9
|
|
10
10
|
attr_accessor :counts
|
11
11
|
attr_accessor :last_checked
|
12
|
+
attr_accessor :count_all
|
12
13
|
|
13
14
|
def configure(conf)
|
14
15
|
super
|
@@ -31,6 +32,7 @@ class Fluent::FlowCounterOutput < Fluent::Output
|
|
31
32
|
@removed_length = @removed_prefix_string.length
|
32
33
|
end
|
33
34
|
@count_keys = @count_keys.split(',')
|
35
|
+
@count_all = (@count_keys == ['*'])
|
34
36
|
|
35
37
|
@counts = count_initialized
|
36
38
|
@mutex = Mutex.new
|
@@ -120,10 +122,17 @@ class Fluent::FlowCounterOutput < Fluent::Output
|
|
120
122
|
name = tag[@removed_length..-1]
|
121
123
|
end
|
122
124
|
c,b = 0,0
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
125
|
+
if @count_all
|
126
|
+
es.each {|time,record|
|
127
|
+
c += 1
|
128
|
+
b += record.keys.inject(0){|s,k| s + record[k].bytesize}
|
129
|
+
}
|
130
|
+
else
|
131
|
+
es.each {|time,record|
|
132
|
+
c += 1
|
133
|
+
b += @count_keys.inject(0){|s,k| s + record[k].bytesize}
|
134
|
+
}
|
135
|
+
end
|
127
136
|
countup(name, c, b)
|
128
137
|
|
129
138
|
chain.next
|
@@ -67,6 +67,19 @@ count_keys message
|
|
67
67
|
assert_equal 'test.flowcount', d.instance.tag
|
68
68
|
assert_equal 'test', d.instance.input_tag_remove_prefix
|
69
69
|
assert_equal ['message'], d.instance.count_keys
|
70
|
+
|
71
|
+
d = create_driver %[
|
72
|
+
unit day
|
73
|
+
aggregate all
|
74
|
+
tag test.flowcount
|
75
|
+
input_tag_remove_prefix test
|
76
|
+
count_keys *
|
77
|
+
]
|
78
|
+
assert_equal :day, d.instance.unit
|
79
|
+
assert_equal :all, d.instance.aggregate
|
80
|
+
assert_equal 'test.flowcount', d.instance.tag
|
81
|
+
assert_equal 'test', d.instance.input_tag_remove_prefix
|
82
|
+
assert d.instance.count_all
|
70
83
|
end
|
71
84
|
|
72
85
|
def test_count_initialized
|
@@ -190,7 +203,33 @@ count_keys message
|
|
190
203
|
d2.instance.flush_emit(60)
|
191
204
|
emits = d2.emits
|
192
205
|
assert_equal 1, emits.length
|
193
|
-
|
206
|
+
data = emits[0]
|
207
|
+
assert_equal 'flowcount', data[0] # tag
|
208
|
+
assert_equal 60*5, data[2]['count']
|
209
|
+
assert_equal 60*5*20, data[2]['bytes']
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_emit3
|
213
|
+
d3 = create_driver( %[
|
214
|
+
unit minute
|
215
|
+
aggregate all
|
216
|
+
tag flowcount
|
217
|
+
input_tag_remove_prefix test
|
218
|
+
count_keys *
|
219
|
+
], 'test.tag3')
|
220
|
+
time = Time.now.to_i
|
221
|
+
d3.run do
|
222
|
+
60.times do
|
223
|
+
d3.emit({'f1' => 'abcde', 'f2' => 'vwxyz', 'f3' => '0123456789'})
|
224
|
+
d3.emit({'f1' => 'abcde', 'f2' => 'vwxyz', 'f3' => '0123456789'})
|
225
|
+
d3.emit({'f1' => 'abcde', 'f2' => 'vwxyz', 'f3' => '0123456789'})
|
226
|
+
d3.emit({'f1' => 'abcde', 'f2' => 'vwxyz', 'f3' => '0123456789'})
|
227
|
+
d3.emit({'f1' => 'abcde', 'f2' => 'vwxyz', 'f3' => '0123456789'})
|
228
|
+
end
|
229
|
+
end
|
230
|
+
d3.instance.flush_emit(60)
|
231
|
+
emits = d3.emits
|
232
|
+
assert_equal 1, emits.length
|
194
233
|
data = emits[0]
|
195
234
|
assert_equal 'flowcount', data[0] # tag
|
196
235
|
assert_equal 60*5, data[2]['count']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flowcounter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -189,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
segments:
|
191
191
|
- 0
|
192
|
-
hash:
|
192
|
+
hash: 3237314410143149168
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
none: false
|
195
195
|
requirements:
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
200
|
rubyforge_project:
|
201
|
-
rubygems_version: 1.8.
|
201
|
+
rubygems_version: 1.8.21
|
202
202
|
signing_key:
|
203
203
|
specification_version: 3
|
204
204
|
summary: Plugin to counts messages/bytes that matches, per minutes/hours/days
|