fluent-plugin-flowcounter-simple 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +7 -1
- data/Gemfile.v0.10 +4 -0
- data/README.md +18 -3
- data/Rakefile +6 -0
- data/examples/filter.conf +13 -0
- data/examples/output.conf +9 -0
- data/fluent-plugin-flowcounter-simple.gemspec +3 -1
- data/lib/fluent/plugin/filter_flowcounter_simple.rb +21 -0
- data/test/helper.rb +9 -0
- data/test/plugin/test_filter_flowcounter_simple.rb +49 -0
- data/test/plugin/test_out_flowcounter_simple.rb +7 -18
- metadata +49 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea1531a6eca03db802d05acb32f7ac39cfd29576
|
4
|
+
data.tar.gz: 6db938ffaa1c09dc074816b6491fc8dfa752b9f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3564af10781be5858eed85223f0657581a7140e729d994fba324bbb0222532d524408a1821182352316657f73f01182254daa62cad3e5de94257ace2b96e7939
|
7
|
+
data.tar.gz: 7b327631a4d0cb1a082d26e0bebb3674549cf4b37184de7057993d942181d1e26d44c6481934d4272235758869383e192d71237cc582e860595535e5e8a0a8ce
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.v0.10
ADDED
data/README.md
CHANGED
@@ -2,14 +2,29 @@
|
|
2
2
|
|
3
3
|
Simple Fluentd Plugin to count number of messages and outputs to log
|
4
4
|
|
5
|
-
## Configuration
|
5
|
+
## Output Plugin Configuration
|
6
6
|
|
7
7
|
<match foo.bar.**>
|
8
8
|
type flowcounter_simple
|
9
9
|
unit second
|
10
|
-
</
|
10
|
+
</match>
|
11
11
|
|
12
|
-
This plugin does not emit, just writes into the log file as
|
12
|
+
This plugin does not emit, just writes counts into the log file as
|
13
|
+
|
14
|
+
plugin:out_flowcounter_simple count:30 indicator:num unit:second
|
15
|
+
|
16
|
+
## Filter Plugin Configuration
|
17
|
+
|
18
|
+
Fluentd >= v0.12
|
19
|
+
|
20
|
+
```apache
|
21
|
+
<filter foo.bar.**>
|
22
|
+
type flowcounter_simple
|
23
|
+
unit second
|
24
|
+
</filter>
|
25
|
+
```
|
26
|
+
|
27
|
+
This filter plugin pass through records, and writes counts into the log file as
|
13
28
|
|
14
29
|
plugin:out_flowcounter_simple count:30 indicator:num unit:second
|
15
30
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-flowcounter-simple"
|
4
|
-
gem.version = "0.0.
|
4
|
+
gem.version = "0.0.4"
|
5
5
|
gem.authors = ["Naotoshi Seo"]
|
6
6
|
gem.email = ["sonots@gmail.com"]
|
7
7
|
gem.summary = %q{Simple Fluentd Plugin to count number of messages and outputs to log}
|
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_development_dependency "rake"
|
19
19
|
gem.add_development_dependency "pry"
|
20
20
|
gem.add_development_dependency "pry-nav"
|
21
|
+
gem.add_development_dependency "test-unit"
|
22
|
+
gem.add_development_dependency "test-unit-rr"
|
21
23
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# I'm lazy to to implement filter plugin. Use output plugin instance
|
2
|
+
require_relative 'out_flowcounter_simple'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
class Fluent::FlowCounterSimpleFilter < Fluent::Filter
|
6
|
+
Fluent::Plugin.register_filter('flowcounter_simple', self)
|
7
|
+
|
8
|
+
extend Forwardable
|
9
|
+
attr_reader :output
|
10
|
+
def_delegators :@output, :configure, :start, :shutdown, :flush_emit
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@output = Fluent::FlowCounterSimpleOutput.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def filter_stream(tag, es)
|
18
|
+
@output.emit(tag, es, Fluent::NullOutputChain.instance)
|
19
|
+
es
|
20
|
+
end
|
21
|
+
end if defined?(Fluent::Filter)
|
data/test/helper.rb
CHANGED
@@ -13,6 +13,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
require 'fluent/test'
|
15
15
|
require 'fluent/plugin/out_flowcounter_simple'
|
16
|
+
require 'fluent/plugin/filter_flowcounter_simple'
|
16
17
|
|
17
18
|
class Test::Unit::TestCase
|
19
|
+
def capture_log(log)
|
20
|
+
tmp = log.out
|
21
|
+
log.out = StringIO.new
|
22
|
+
yield
|
23
|
+
return log.out.string
|
24
|
+
ensure
|
25
|
+
log.out = tmp
|
26
|
+
end
|
18
27
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require "test/unit/rr"
|
3
|
+
|
4
|
+
class FlowCounterSimpleFilterTest < Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
|
+
def setup
|
8
|
+
Fluent::Test.setup
|
9
|
+
@time = Fluent::Engine.now
|
10
|
+
end
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
unit second
|
14
|
+
]
|
15
|
+
|
16
|
+
def create_driver(conf = CONFIG)
|
17
|
+
Fluent::Test::FilterTestDriver.new(Fluent::FlowCounterSimpleFilter).configure(conf, true)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_filter
|
21
|
+
msgs = []
|
22
|
+
10.times do
|
23
|
+
msgs << {'message'=> 'a' * 100}
|
24
|
+
msgs << {'message'=> 'b' * 100}
|
25
|
+
end
|
26
|
+
d = create_driver
|
27
|
+
filtered, out = filter(d, msgs)
|
28
|
+
assert_equal msgs, filtered
|
29
|
+
assert( out.include?("count:20"), out )
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def filter(d, msgs)
|
35
|
+
stub(d.instance.output).start
|
36
|
+
stub(d.instance.output).shutdown
|
37
|
+
d.run {
|
38
|
+
msgs.each {|msg|
|
39
|
+
d.filter(msg, @time)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
out = capture_log(d.instance.output.log) do
|
43
|
+
d.instance.flush_emit(0)
|
44
|
+
end
|
45
|
+
filtered = d.filtered_as_array
|
46
|
+
filtered_msgs = filtered.map {|m| m[2] }
|
47
|
+
[filtered_msgs, out]
|
48
|
+
end
|
49
|
+
end if defined?(Fluent::Filter)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../helper'
|
2
2
|
|
3
3
|
class FlowCounterSimpleOutputTest < Test::Unit::TestCase
|
4
4
|
def setup
|
@@ -37,8 +37,8 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
|
|
37
37
|
d1.emit({'message'=> 'c' * 100})
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
41
|
-
assert(
|
40
|
+
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
|
41
|
+
assert( out.include?("count:30"), out )
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_byte
|
@@ -50,8 +50,8 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
|
|
50
50
|
d1.emit({'message'=> 'c' * 100})
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
assert(
|
53
|
+
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
|
54
|
+
assert( out.include?("count:3360"), out )
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_comment
|
@@ -63,18 +63,7 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
|
|
63
63
|
d1.emit({'message'=> 'c' * 100})
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
|
-
assert(
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def capture_log
|
73
|
-
tmp = $log.out
|
74
|
-
$log.out = StringIO.new
|
75
|
-
yield
|
76
|
-
return $log.out.string
|
77
|
-
ensure
|
78
|
-
$log.out = tmp
|
66
|
+
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
|
67
|
+
assert( out.include?("comment:foobar"), out )
|
79
68
|
end
|
80
69
|
end
|
metadata
CHANGED
@@ -1,69 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flowcounter-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
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: :runtime
|
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: rake
|
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: :development
|
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: pry
|
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: :development
|
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
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry-nav
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit-rr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
description: Simple Fluentd Plugin to count number of messages and outputs to log
|
@@ -73,16 +101,21 @@ executables: []
|
|
73
101
|
extensions: []
|
74
102
|
extra_rdoc_files: []
|
75
103
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
78
106
|
- CHANGELOG.md
|
79
107
|
- Gemfile
|
108
|
+
- Gemfile.v0.10
|
80
109
|
- LICENSE.txt
|
81
110
|
- README.md
|
82
111
|
- Rakefile
|
112
|
+
- examples/filter.conf
|
113
|
+
- examples/output.conf
|
83
114
|
- fluent-plugin-flowcounter-simple.gemspec
|
115
|
+
- lib/fluent/plugin/filter_flowcounter_simple.rb
|
84
116
|
- lib/fluent/plugin/out_flowcounter_simple.rb
|
85
117
|
- test/helper.rb
|
118
|
+
- test/plugin/test_filter_flowcounter_simple.rb
|
86
119
|
- test/plugin/test_out_flowcounter_simple.rb
|
87
120
|
homepage: https://github.com/sonots/fluent-plugin-flowcounter-simple
|
88
121
|
licenses:
|
@@ -94,20 +127,21 @@ require_paths:
|
|
94
127
|
- lib
|
95
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
129
|
requirements:
|
97
|
-
- -
|
130
|
+
- - ">="
|
98
131
|
- !ruby/object:Gem::Version
|
99
132
|
version: '0'
|
100
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
134
|
requirements:
|
102
|
-
- -
|
135
|
+
- - ">="
|
103
136
|
- !ruby/object:Gem::Version
|
104
137
|
version: '0'
|
105
138
|
requirements: []
|
106
139
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.2.2
|
108
141
|
signing_key:
|
109
142
|
specification_version: 4
|
110
143
|
summary: Simple Fluentd Plugin to count number of messages and outputs to log
|
111
144
|
test_files:
|
112
145
|
- test/helper.rb
|
146
|
+
- test/plugin/test_filter_flowcounter_simple.rb
|
113
147
|
- test/plugin/test_out_flowcounter_simple.rb
|