fluent-plugin-add 0.0.4 → 0.0.5
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/.travis.yml +2 -0
- data/README.md +7 -3
- data/fluent-plugin-add.gemspec +1 -1
- data/lib/fluent/plugin/filter_add.rb +6 -0
- data/lib/fluent/plugin/out_add.rb +6 -0
- data/test/plugin/test_filter_add.rb +19 -1
- data/test/plugin/test_out_add.rb +20 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49afbd4154aa23838bdccfb5e610d1099d066048
|
4
|
+
data.tar.gz: 08b553378ac23e984a875cd3cfcfd70afa5c70a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15db222b1240c519cb627980e7a500a876ae1a014623061cae04c6106d2a5bacac30d638b249bb3878cd70ee981a8cc3b7085e648cf638b74f23b2525d5fbbdd
|
7
|
+
data.tar.gz: bc449cb6eeaec314ba97e7ca76ec029520386949ed560b104beb4673da0cbc8ed938dd625554a832c4cbb0ef38579ac74b0eea5c4c2a04877dd67c010e73a746
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# fluent-plugin-add, a plugin for [Fluentd](http://fluentd.org)
|
2
2
|
[](https://travis-ci.org/yu-yamada/fluent-plugin-add)
|
3
3
|
|
4
|
+
[](https://badge.fury.io/rb/fluent-plugin-add)
|
5
|
+
|
4
6
|
## Installation
|
5
7
|
|
6
8
|
|
@@ -13,6 +15,7 @@
|
|
13
15
|
<match test.**>
|
14
16
|
type add
|
15
17
|
add_tag_prefix debug
|
18
|
+
uuid true # optional
|
16
19
|
<pair>
|
17
20
|
hoge moge
|
18
21
|
hogehoge mogemoge
|
@@ -22,13 +25,14 @@
|
|
22
25
|
|
23
26
|
### Assuming following inputs are coming:
|
24
27
|
test.aa: {"json":"dayo"}
|
25
|
-
### then output
|
26
|
-
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge"}
|
28
|
+
### then output becomes as belows
|
29
|
+
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge","uuid":"427037E7-235B-4F6C-9975-15AAC75E56C5"}
|
27
30
|
|
28
31
|
### AddFilter
|
29
32
|
|
30
33
|
<filter test.**>
|
31
34
|
type add
|
35
|
+
uuid true # optional
|
32
36
|
<pair>
|
33
37
|
hoge moge
|
34
38
|
hogehoge mogemoge
|
@@ -39,7 +43,7 @@
|
|
39
43
|
### Assuming following inputs are coming:
|
40
44
|
test.aa: {"json":"dayo"}
|
41
45
|
### then output bocomes as belows
|
42
|
-
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge"}
|
46
|
+
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge","uuid":"427037E7-235B-4F6C-9975-15AAC75E56C5"}
|
43
47
|
|
44
48
|
## Contributing
|
45
49
|
|
data/fluent-plugin-add.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "fluent-plugin-add"
|
8
|
-
spec.version = "0.0.
|
8
|
+
spec.version = "0.0.5"
|
9
9
|
spec.authors = ["yu yamada"]
|
10
10
|
spec.email = ["yu.yamada07@gmail.com"]
|
11
11
|
spec.description = %q{Output filter plugin to add messages}
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
class Fluent::AddFilter < Fluent::Filter
|
2
4
|
Fluent::Plugin.register_filter('add', self)
|
3
5
|
|
6
|
+
config_param :uuid, :bool, :default => false
|
4
7
|
def initialize
|
5
8
|
super
|
6
9
|
end
|
@@ -23,6 +26,9 @@ class Fluent::AddFilter < Fluent::Filter
|
|
23
26
|
@add_hash.each do |k,v|
|
24
27
|
record[k] = v
|
25
28
|
end
|
29
|
+
if @uuid
|
30
|
+
record['uuid'] = SecureRandom.uuid.upcase
|
31
|
+
end
|
26
32
|
record
|
27
33
|
end
|
28
34
|
end if defined?(Fluent::Filter)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
class Fluent::AddOutput < Fluent::Output
|
2
4
|
Fluent::Plugin.register_output('add', self)
|
3
5
|
|
@@ -7,6 +9,7 @@ class Fluent::AddOutput < Fluent::Output
|
|
7
9
|
end
|
8
10
|
|
9
11
|
config_param :add_tag_prefix, :string, :default => 'greped'
|
12
|
+
config_param :uuid, :bool, :default => false
|
10
13
|
|
11
14
|
def initialize
|
12
15
|
super
|
@@ -40,6 +43,9 @@ class Fluent::AddOutput < Fluent::Output
|
|
40
43
|
@add_hash.each do |k,v|
|
41
44
|
record[k] = v
|
42
45
|
end
|
46
|
+
if @uuid
|
47
|
+
record['uuid'] = SecureRandom.uuid.upcase
|
48
|
+
end
|
43
49
|
router.emit(emit_tag, time, record)
|
44
50
|
end
|
45
51
|
|
@@ -13,13 +13,21 @@ class AddFilterTest < Test::Unit::TestCase
|
|
13
13
|
hogehoge mogemoge
|
14
14
|
</pair>
|
15
15
|
]
|
16
|
+
CONFIG_UU = %[
|
17
|
+
uuid true
|
18
|
+
<pair>
|
19
|
+
hoge moge
|
20
|
+
hogehoge mogemoge
|
21
|
+
</pair>
|
22
|
+
]
|
16
23
|
|
17
24
|
def create_driver(conf = CONFIG, tag='test')
|
18
25
|
Fluent::Test::FilterTestDriver.new(Fluent::AddFilter, tag).configure(conf)
|
19
26
|
end
|
20
27
|
|
21
28
|
def test_configure
|
22
|
-
d = create_driver
|
29
|
+
d = create_driver(CONFIG_UU)
|
30
|
+
assert d.instance.config["uuid"]
|
23
31
|
end
|
24
32
|
|
25
33
|
def test_format
|
@@ -33,4 +41,14 @@ class AddFilterTest < Test::Unit::TestCase
|
|
33
41
|
expect = {"a" => 1}.merge(mapped)
|
34
42
|
assert_equal expect, d.filtered_as_array[0][2]
|
35
43
|
end
|
44
|
+
def test_uu
|
45
|
+
d = create_driver(CONFIG_UU)
|
46
|
+
|
47
|
+
d.run do
|
48
|
+
d.emit("a" => 1)
|
49
|
+
end
|
50
|
+
assert d.filtered_as_array[0][2].has_key?('uuid')
|
51
|
+
|
52
|
+
d.run
|
53
|
+
end
|
36
54
|
end
|
data/test/plugin/test_out_add.rb
CHANGED
@@ -12,6 +12,13 @@ class AddOutputTest < Test::Unit::TestCase
|
|
12
12
|
hogehoge mogemoge
|
13
13
|
</pair>
|
14
14
|
]
|
15
|
+
CONFIG_UU = %[
|
16
|
+
uuid true
|
17
|
+
<pair>
|
18
|
+
hoge moge
|
19
|
+
hogehoge mogemoge
|
20
|
+
</pair>
|
21
|
+
]
|
15
22
|
|
16
23
|
def create_driver(conf = CONFIG, tag='test')
|
17
24
|
Fluent::Test::OutputTestDriver.new(Fluent::AddOutput, tag).configure(conf)
|
@@ -20,12 +27,14 @@ class AddOutputTest < Test::Unit::TestCase
|
|
20
27
|
def test_configure
|
21
28
|
d = create_driver
|
22
29
|
assert_equal 'pre_hoge', d.instance.config["add_tag_prefix"]
|
30
|
+
|
31
|
+
d = create_driver(CONFIG_UU)
|
32
|
+
assert d.instance.config["uuid"]
|
23
33
|
end
|
24
34
|
|
25
35
|
def test_format
|
26
36
|
d = create_driver
|
27
37
|
|
28
|
-
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
29
38
|
d.run do
|
30
39
|
d.emit("a" => 1)
|
31
40
|
end
|
@@ -34,6 +43,16 @@ class AddOutputTest < Test::Unit::TestCase
|
|
34
43
|
{"a" => 1}.merge(mapped),
|
35
44
|
], d.records
|
36
45
|
|
46
|
+
d.run
|
47
|
+
end
|
48
|
+
def test_uu
|
49
|
+
d = create_driver(CONFIG_UU)
|
50
|
+
|
51
|
+
d.run do
|
52
|
+
d.emit("a" => 1)
|
53
|
+
end
|
54
|
+
assert d.records[0].has_key?('uuid')
|
55
|
+
|
37
56
|
d.run
|
38
57
|
end
|
39
58
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-add
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yu yamada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
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: '1.3'
|
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: test-unit
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.1.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: 3.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fluentd
|
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: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Output filter plugin to add messages
|
@@ -73,8 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
77
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
@@ -95,17 +95,17 @@ require_paths:
|
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - '>='
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - '>='
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.0.14.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Output filter plugin to add messages
|