fluent-plugin-array-splitter 0.1.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 +7 -0
- data/.gitignore +55 -0
- data/Gemfile +3 -0
- data/README.md +43 -0
- data/Rakefile +13 -0
- data/fluent-plugin-array-splitter.gemspec +27 -0
- data/lib/fluent/plugin/filter_array_splitter.rb +42 -0
- data/test/helper.rb +7 -0
- data/test/plugin/test_filter_array_splitter.rb +35 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b744e9de9c27aef607ee4954f10942b1a1de51ed36767ead52026abe028b171
|
4
|
+
data.tar.gz: b456cd234a8940164f8d4efd4372724224fb504cd55ab5b81a4435445a2d5655
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d666f6b204fd61c70a2e033edce5fde4a174d8e36e549eda9330b97bf5cc47eb9ad994e088185e56cda0884728546090095b532896ee28f6985c6675c609ee9b
|
7
|
+
data.tar.gz: b39b59481bf68ffe1b1831904d1a356fc5a4567818419e30881f882bd81a3ceed9755d101c81634136c6fef2c53a5d029da4c23f7c8c87505d1cf76f0c25e4ea
|
data/.gitignore
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# fluent-plugin-array-splitter
|
2
|
+
|
3
|
+
[Fluentd](https://fluentd.org/) filter plugin to do something.
|
4
|
+
|
5
|
+
TODO: write description for you plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### RubyGems
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install fluent-plugin-array-splitter
|
13
|
+
```
|
14
|
+
|
15
|
+
### Bundler
|
16
|
+
|
17
|
+
Add following line to your Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem "fluent-plugin-array-splitter"
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ bundle
|
27
|
+
```
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
You can generate configuration template:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ fluent-plugin-config-format filter array_splitter
|
35
|
+
```
|
36
|
+
|
37
|
+
You can copy and paste generated documents here.
|
38
|
+
|
39
|
+
## Copyright
|
40
|
+
|
41
|
+
* Copyright(c) 2023- pcoffmanjr
|
42
|
+
* License
|
43
|
+
*
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs.push("lib", "test")
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
t.warning = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: [:test]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "fluent-plugin-array-splitter"
|
6
|
+
spec.version = "0.1.0"
|
7
|
+
spec.authors = ["pcoffmanjr"]
|
8
|
+
spec.email = ["pcoffman@ctc-america.com"]
|
9
|
+
|
10
|
+
spec.summary = %q{A Fluentd plugin to split array values into separate records.}
|
11
|
+
spec.description = %q{This Fluentd plugin takes array values from a specified field and creates separate records for each array element.}
|
12
|
+
spec.homepage = "https://github.com/paulcoffmanjr/fluent-plugin-array-splitter"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
test_files, files = `git ls-files -z`.split("\x0").partition do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.files = files
|
19
|
+
spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = test_files
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.1.2"
|
24
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
25
|
+
spec.add_development_dependency "test-unit", "~> 3.3.9"
|
26
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require "fluent/plugin/filter"
|
4
|
+
|
5
|
+
module Fluent
|
6
|
+
module Plugin
|
7
|
+
class ArraySplitterFilter < Fluent::Plugin::Filter
|
8
|
+
Fluent::Plugin.register_filter("array_splitter", self)
|
9
|
+
|
10
|
+
def configure(conf)
|
11
|
+
super
|
12
|
+
log.info "Configuring Array Splitter Filter"
|
13
|
+
end
|
14
|
+
|
15
|
+
def filter_stream(tag, es)
|
16
|
+
new_es = Fluent::MultiEventStream.new
|
17
|
+
es.each do |time, record|
|
18
|
+
if record['message'].is_a?(Array)
|
19
|
+
record['message'].each do |value|
|
20
|
+
new_record = record.dup
|
21
|
+
new_record['message'] = value
|
22
|
+
new_es.add(time, new_record)
|
23
|
+
end
|
24
|
+
elsif record['target_field'].is_a?(Array)
|
25
|
+
record['target_field'].each do |hash|
|
26
|
+
hash.each do |k, v|
|
27
|
+
new_record = record.dup
|
28
|
+
new_record.delete('target_field')
|
29
|
+
new_record[k] = v
|
30
|
+
new_es.add(time, new_record)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
else
|
34
|
+
new_es.add(time, record)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
new_es
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/filter_array_splitter.rb"
|
3
|
+
|
4
|
+
class ArraySplitterFilterTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
Fluent::Test.setup
|
7
|
+
@driver = create_driver
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_driver(conf = "")
|
11
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::ArraySplitterFilter).configure(Fluent::Config.parse(conf, "(test)", "(test_dir)", true))
|
12
|
+
end
|
13
|
+
|
14
|
+
sub_test_case "filter" do
|
15
|
+
test "expand array in message field" do
|
16
|
+
record = {
|
17
|
+
"key1" => "hoge",
|
18
|
+
"key2" => "foo",
|
19
|
+
"key3" => "bar",
|
20
|
+
"message" => ["v1", "v2", "v3"]
|
21
|
+
}
|
22
|
+
@driver.run(default_tag: "test") do
|
23
|
+
@driver.feed(record)
|
24
|
+
end
|
25
|
+
filtered_records = @driver.filtered_records
|
26
|
+
assert_equal(3, filtered_records.size)
|
27
|
+
assert_equal("v1", filtered_records[0]["message"])
|
28
|
+
assert_equal("v2", filtered_records[1]["message"])
|
29
|
+
assert_equal("v3", filtered_records[2]["message"])
|
30
|
+
end
|
31
|
+
|
32
|
+
# More tests for other cases...
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-array-splitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pcoffmanjr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.2
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 13.0.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 13.0.6
|
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.3.9
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.3.9
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluentd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.10
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '2'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.14.10
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2'
|
75
|
+
description: This Fluentd plugin takes array values from a specified field and creates
|
76
|
+
separate records for each array element.
|
77
|
+
email:
|
78
|
+
- pcoffman@ctc-america.com
|
79
|
+
executables: []
|
80
|
+
extensions: []
|
81
|
+
extra_rdoc_files: []
|
82
|
+
files:
|
83
|
+
- ".gitignore"
|
84
|
+
- Gemfile
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- fluent-plugin-array-splitter.gemspec
|
88
|
+
- lib/fluent/plugin/filter_array_splitter.rb
|
89
|
+
- test/helper.rb
|
90
|
+
- test/plugin/test_filter_array_splitter.rb
|
91
|
+
homepage: https://github.com/paulcoffmanjr/fluent-plugin-array-splitter
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.1.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: A Fluentd plugin to split array values into separate records.
|
114
|
+
test_files:
|
115
|
+
- test/helper.rb
|
116
|
+
- test/plugin/test_filter_array_splitter.rb
|