fluent-plugin-split-array 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +56 -0
- data/Rakefile +11 -0
- data/fluent-plugin-split-array.gemspec +17 -0
- data/lib/fluent/plugin/filter_split_array.rb +20 -0
- data/test/plugin/test_filter_split_array.rb +35 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5dab092bbda0d51379b1f6904eacc5b57c401815
|
4
|
+
data.tar.gz: 1c7d3b332207192f753131fe9874ae09b3af3b33
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fe87ceb5e1d88bdadc7f76093d1a22f26d0b8b62da54076a08ec4efe44af9d588305573617ff55b3e6a2e5aa9aec7031cc3411a54f8d12d023c9c41903989c59
|
7
|
+
data.tar.gz: 0d286ea60ebff851788dc2b5ae7426b3d8b7e157380a86ef5001b7064a01a12f1b88ea9b3ae3142b94cdedb5674342c7e852f2f1a98d34259bd8c6a023281c19
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 SNakano
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# fluent-plugin-split-array
|
2
|
+
|
3
|
+
Fluent filter plugin to split array
|
4
|
+
|
5
|
+
## install
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install fluent-plugin-split-array
|
9
|
+
```
|
10
|
+
|
11
|
+
## Configuration Example
|
12
|
+
|
13
|
+
```
|
14
|
+
<filter foo.bar.*>
|
15
|
+
type split_array
|
16
|
+
</filter>
|
17
|
+
```
|
18
|
+
|
19
|
+
## Example 1
|
20
|
+
|
21
|
+
### input
|
22
|
+
|
23
|
+
```
|
24
|
+
[{'a' => 'b'}, {'a' => 'c'}]
|
25
|
+
```
|
26
|
+
|
27
|
+
### output
|
28
|
+
|
29
|
+
```
|
30
|
+
{'a' => 'b'}
|
31
|
+
{'a' => 'c'}
|
32
|
+
```
|
33
|
+
|
34
|
+
## Example 2
|
35
|
+
|
36
|
+
### fluent.conf
|
37
|
+
|
38
|
+
Monitoring RabbitMQ all queues status
|
39
|
+
```
|
40
|
+
<source>
|
41
|
+
type exec
|
42
|
+
command curl -s -u guest:gutest http://127.0.0.1:15672/api/queues
|
43
|
+
format json
|
44
|
+
tag rabbitmq
|
45
|
+
run_interval 10s
|
46
|
+
</source>
|
47
|
+
|
48
|
+
<filter rabbitmq>
|
49
|
+
type split_array
|
50
|
+
</filter>
|
51
|
+
|
52
|
+
<match rabbitmq>
|
53
|
+
type stdout
|
54
|
+
</match>
|
55
|
+
```
|
56
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "fluent-plugin-split-array"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.licenses = ["MIT"]
|
5
|
+
s.summary = "Fluentd filter plugin to split array"
|
6
|
+
s.description = s.summary
|
7
|
+
s.authors = ["SNakano"]
|
8
|
+
s.email = ["pp.nakano@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/SNakano/fluent-plugin-split-array"
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
|
14
|
+
s.add_runtime_dependency "fluentd", "~> 0.12"
|
15
|
+
s.add_development_dependency "rake", "~> 10.4"
|
16
|
+
s.add_development_dependency "test-unit", "~> 3.1"
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fluent
|
2
|
+
class SplitArrayFilter < Filter
|
3
|
+
Fluent::Plugin.register_filter('split_array', self)
|
4
|
+
def filter_stream(tag, es)
|
5
|
+
new_es = MultiEventStream.new
|
6
|
+
es.each {|time, record| split(time, record, new_es) }
|
7
|
+
new_es
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def split(time, record, new_es)
|
13
|
+
if record.instance_of?(Array)
|
14
|
+
record.each { |r| new_es.add(time, r) }
|
15
|
+
else
|
16
|
+
new_es.add(time, record)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/log'
|
3
|
+
require 'fluent/test'
|
4
|
+
require 'fluent/plugin/filter_split_array'
|
5
|
+
|
6
|
+
class RubyFilterTest < Test::Unit::TestCase
|
7
|
+
include Fluent
|
8
|
+
|
9
|
+
setup do
|
10
|
+
Fluent::Test.setup
|
11
|
+
end
|
12
|
+
|
13
|
+
def emit(msg)
|
14
|
+
d = Test::FilterTestDriver.new(SplitArrayFilter).configure('', true)
|
15
|
+
d.run {
|
16
|
+
d.emit(msg, Fluent::Engine.now)
|
17
|
+
}.filtered
|
18
|
+
end
|
19
|
+
|
20
|
+
sub_test_case 'filter' do
|
21
|
+
test 'execute to array' do
|
22
|
+
msg = [{'a' => 'b'}, {'a' => 'c'}]
|
23
|
+
es = emit(msg)
|
24
|
+
assert_equal(msg.count, es.count)
|
25
|
+
es.each_with_index do |e, i|
|
26
|
+
assert_equal(msg[i], e[1])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
test 'execute to hash' do
|
30
|
+
msg = {'a' => 'b', 'c' => 'd'}
|
31
|
+
es = emit(msg)
|
32
|
+
assert_equal(msg, es.first[1])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-split-array
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SNakano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
description: Fluentd filter plugin to split array
|
56
|
+
email:
|
57
|
+
- pp.nakano@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- fluent-plugin-split-array.gemspec
|
67
|
+
- lib/fluent/plugin/filter_split_array.rb
|
68
|
+
- test/plugin/test_filter_split_array.rb
|
69
|
+
homepage: https://github.com/SNakano/fluent-plugin-split-array
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.5.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Fluentd filter plugin to split array
|
93
|
+
test_files:
|
94
|
+
- test/plugin/test_filter_split_array.rb
|