fluent-plugin-flowcounter 0.1.9 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/fluent-plugin-flowcounter.gemspec +1 -1
- data/lib/fluent/plugin/out_flowcounter.rb +17 -9
- data/test/plugin/test_out_flowcounter.rb +18 -0
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2c1125317b984edda98fd4811d0263028ceead
|
4
|
+
data.tar.gz: 3d60b7b9e9358570806138fa7e317a0a24a06272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab1a0ddf3e18281456030574881e57fc0464fc9f83091f21462e16e9bfaa01859a90f1cdbe725d03f46184c2ed4ba0df3ee38ad58249fbba6f6ca12dda36c717
|
7
|
+
data.tar.gz: 084cb3293584dd6278bb936a9a163db4080027da94c8b6d3512e6f17a0cdbe750ee5525ac2ddb963f8f15f1f3c656baa43d30b7efa539c4d916df3a80111b779
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# fluent-plugin-flowcounter
|
2
2
|
|
3
|
-
Count
|
3
|
+
Count metrics below about matches. This is a plugin for [Fluentd](http://fluentd.org)
|
4
4
|
|
5
|
-
* Messages per minute/hour/day
|
6
|
-
* Bytes per minute/hour/day
|
7
|
-
* Messages per second (average every minute/hour/day)
|
8
|
-
* Bytes per second (average every minute/hour/day)
|
5
|
+
* Messages per second/minute/hour/day
|
6
|
+
* Bytes per second/minute/hour/day
|
7
|
+
* Messages per second (average every second/minute/hour/day)
|
8
|
+
* Bytes per second (average every second/minute/hour/day)
|
9
9
|
|
10
10
|
FlowCounterOutput emits messages contains results data, so you can output these message (with 'flowcount' tag by default) to any outputs you want.
|
11
11
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-flowcounter"
|
4
|
-
gem.version = "0.
|
4
|
+
gem.version = "0.2.0"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.summary = %q{Fluent plugin to count message flow}
|
@@ -3,6 +3,11 @@ require 'fluent/mixin/config_placeholders'
|
|
3
3
|
class Fluent::FlowCounterOutput < Fluent::Output
|
4
4
|
Fluent::Plugin.register_output('flowcounter', self)
|
5
5
|
|
6
|
+
# Define `log` method for v0.10.42 or earlier
|
7
|
+
unless method_defined?(:log)
|
8
|
+
define_method("log") { $log }
|
9
|
+
end
|
10
|
+
|
6
11
|
config_param :unit, :string, :default => 'minute'
|
7
12
|
config_param :aggregate, :string, :default => 'tag'
|
8
13
|
config_param :output_style, :string, :default => 'joined'
|
@@ -15,16 +20,26 @@ class Fluent::FlowCounterOutput < Fluent::Output
|
|
15
20
|
attr_accessor :counts
|
16
21
|
attr_accessor :last_checked
|
17
22
|
attr_accessor :count_all
|
23
|
+
attr_reader :tick
|
18
24
|
|
19
25
|
def configure(conf)
|
20
26
|
super
|
21
27
|
|
22
28
|
@unit = case @unit
|
29
|
+
when 'second' then :second
|
23
30
|
when 'minute' then :minute
|
24
31
|
when 'hour' then :hour
|
25
32
|
when 'day' then :day
|
26
33
|
else
|
27
|
-
raise Fluent::ConfigError, "flowcounter unit allows minute/hour/day"
|
34
|
+
raise Fluent::ConfigError, "flowcounter unit allows second/minute/hour/day"
|
35
|
+
end
|
36
|
+
@tick = case @unit
|
37
|
+
when :second then 1
|
38
|
+
when :minute then 60
|
39
|
+
when :hour then 3600
|
40
|
+
when :day then 86400
|
41
|
+
else
|
42
|
+
raise Fluent::ConfigError, "flowcounter unit allows second/minute/hour/day"
|
28
43
|
end
|
29
44
|
@aggregate = case @aggregate
|
30
45
|
when 'tag' then :tag
|
@@ -132,16 +147,9 @@ class Fluent::FlowCounterOutput < Fluent::Output
|
|
132
147
|
def watch
|
133
148
|
# instance variable, and public accessable, for test
|
134
149
|
@last_checked = Fluent::Engine.now
|
135
|
-
tick = case @unit
|
136
|
-
when :minute then 60
|
137
|
-
when :hour then 3600
|
138
|
-
when :day then 86400
|
139
|
-
else
|
140
|
-
raise RuntimeError, "@unit must be one of minute/hour/day"
|
141
|
-
end
|
142
150
|
while true
|
143
151
|
sleep 0.5
|
144
|
-
if Fluent::Engine.now - @last_checked >= tick
|
152
|
+
if Fluent::Engine.now - @last_checked >= @tick
|
145
153
|
now = Fluent::Engine.now
|
146
154
|
flush_emit(now - @last_checked)
|
147
155
|
@last_checked = now
|
@@ -31,6 +31,7 @@ count_keys message
|
|
31
31
|
count_keys message
|
32
32
|
]
|
33
33
|
assert_equal :minute, d.instance.unit
|
34
|
+
assert_equal 60, d.instance.tick
|
34
35
|
assert_equal :tag, d.instance.aggregate
|
35
36
|
assert_equal :joined, d.instance.output_style
|
36
37
|
assert_equal 'flowcount', d.instance.tag
|
@@ -41,17 +42,31 @@ count_keys message
|
|
41
42
|
count_keys field1,field2
|
42
43
|
]
|
43
44
|
assert_equal :minute, d.instance.unit
|
45
|
+
assert_equal 60, d.instance.tick
|
44
46
|
assert_equal :tag, d.instance.aggregate
|
45
47
|
assert_equal :joined, d.instance.output_style
|
46
48
|
assert_equal 'flowcount', d.instance.tag
|
47
49
|
assert_nil d.instance.input_tag_remove_prefix
|
48
50
|
assert_equal ['field1', 'field2'], d.instance.count_keys
|
49
51
|
|
52
|
+
d = create_driver %[
|
53
|
+
unit second
|
54
|
+
count_keys message
|
55
|
+
]
|
56
|
+
assert_equal :second, d.instance.unit
|
57
|
+
assert_equal 1, d.instance.tick
|
58
|
+
assert_equal :tag, d.instance.aggregate
|
59
|
+
assert_equal :joined, d.instance.output_style
|
60
|
+
assert_equal 'flowcount', d.instance.tag
|
61
|
+
assert_nil d.instance.input_tag_remove_prefix
|
62
|
+
assert_equal ['message'], d.instance.count_keys
|
63
|
+
|
50
64
|
d = create_driver %[
|
51
65
|
unit hour
|
52
66
|
count_keys message
|
53
67
|
]
|
54
68
|
assert_equal :hour, d.instance.unit
|
69
|
+
assert_equal 3600, d.instance.tick
|
55
70
|
assert_equal :tag, d.instance.aggregate
|
56
71
|
assert_equal :joined, d.instance.output_style
|
57
72
|
assert_equal 'flowcount', d.instance.tag
|
@@ -63,6 +78,7 @@ count_keys message
|
|
63
78
|
count_keys message
|
64
79
|
]
|
65
80
|
assert_equal :minute, d.instance.unit
|
81
|
+
assert_equal 60, d.instance.tick
|
66
82
|
assert_equal :tag, d.instance.aggregate
|
67
83
|
assert_equal :tagged, d.instance.output_style
|
68
84
|
assert_equal 'flowcount', d.instance.tag
|
@@ -77,6 +93,7 @@ count_keys message
|
|
77
93
|
count_keys message
|
78
94
|
]
|
79
95
|
assert_equal :day, d.instance.unit
|
96
|
+
assert_equal 86400, d.instance.tick
|
80
97
|
assert_equal :all, d.instance.aggregate
|
81
98
|
assert_equal :joined, d.instance.output_style
|
82
99
|
assert_equal 'test.flowcount', d.instance.tag
|
@@ -91,6 +108,7 @@ count_keys message
|
|
91
108
|
count_keys *
|
92
109
|
]
|
93
110
|
assert_equal :day, d.instance.unit
|
111
|
+
assert_equal 86400, d.instance.tick
|
94
112
|
assert_equal :all, d.instance.aggregate
|
95
113
|
assert_equal :joined, d.instance.output_style
|
96
114
|
assert_equal 'test.flowcount', d.instance.tag
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flowcounter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fluentd
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: fluent-mixin-config-placeholders
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Plugin to counts messages/bytes that matches, per minutes/hours/days
|
@@ -59,9 +59,9 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .document
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
62
|
+
- ".document"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- AUTHORS
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE.txt
|
@@ -81,21 +81,20 @@ require_paths:
|
|
81
81
|
- lib
|
82
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- -
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.2.2
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Fluent plugin to count message flow
|
98
98
|
test_files:
|
99
99
|
- test/helper.rb
|
100
100
|
- test/plugin/test_out_flowcounter.rb
|
101
|
-
has_rdoc:
|