fluent-plugin-split 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/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +63 -0
- data/Rakefile +15 -0
- data/fluent-plugin-split.gemspec +21 -0
- data/lib/fluent/plugin/out_split.rb +45 -0
- data/spec/out_split_spec.rb +15 -0
- data/spec/spec_helper.rb +13 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2889b1272cbbee83372b3376b22e17f5fbe897a
|
4
|
+
data.tar.gz: efdec127d0aeb986b9eb11913d6867a23fb85a8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a3291b5e20dc73a21e8212abdfebd020d812fdb77f44b7b09763ced5c4d3789a63eeed10c9767a3b3a8d065fedb63423bcfeb05c26bc975a4694076e262217c
|
7
|
+
data.tar.gz: 327798f399b83279ae02d70f437688680f4ae69bcfdd822e9ea560c190b5e83aee195a2b12a3f185ba7b73450b29f20466ed6e32f82fc21ded655b6684efff18
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Hiroshi Toyama
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# fluent-plugin-split
|
2
|
+
|
3
|
+
Output Split String Plugin for fluentd
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Use RubyGems:
|
8
|
+
|
9
|
+
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-split
|
10
|
+
|
11
|
+
|
12
|
+
## parameter
|
13
|
+
|
14
|
+
param | value
|
15
|
+
--------|------
|
16
|
+
output_tag|output tag
|
17
|
+
output_key|output split word key
|
18
|
+
format|csv or tsv or space
|
19
|
+
key_name|target key name
|
20
|
+
keep_keys|keep keys(comma separator)
|
21
|
+
|
22
|
+
## Configuration
|
23
|
+
|
24
|
+
Example:
|
25
|
+
|
26
|
+
<match tag>
|
27
|
+
type split
|
28
|
+
output_tag split.keyword
|
29
|
+
output_key keyword
|
30
|
+
format csv
|
31
|
+
key_name keywords
|
32
|
+
keep_keys site
|
33
|
+
</match>
|
34
|
+
|
35
|
+
Assume following input is coming:
|
36
|
+
|
37
|
+
```js
|
38
|
+
foo.bar {"keywords"=>"keyword1,keyword2,keyword3", "site" => "google", "user_id" => "1"}
|
39
|
+
```
|
40
|
+
|
41
|
+
then output becomes as below (indented):
|
42
|
+
|
43
|
+
```js
|
44
|
+
split.keyword { "keyword":"keyword1", "site" => "google"}
|
45
|
+
split.keyword { "keyword":"keyword2", "site" => "google"}
|
46
|
+
split.keyword { "keyword":"keyword3", "site" => "google"}
|
47
|
+
```
|
48
|
+
|
49
|
+
## ChangeLog
|
50
|
+
|
51
|
+
See [CHANGELOG.md](CHANGELOG.md) for details.
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create new [Pull Request](../../pull/new/master)
|
60
|
+
|
61
|
+
## Copyright
|
62
|
+
|
63
|
+
Copyright (c) 2013 Hiroshi Toyama. See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Open an irb session preloaded with the gem library'
|
12
|
+
task :console do
|
13
|
+
sh 'irb -rubygems -I lib'
|
14
|
+
end
|
15
|
+
task :c => :console
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-split"
|
6
|
+
gem.version = "0.0.1"
|
7
|
+
gem.authors = ["Hiroshi Toyama"]
|
8
|
+
gem.email = "toyama0919@gmail.com"
|
9
|
+
gem.homepage = "https://github.com/toyama0919/fluent-plugin-split"
|
10
|
+
gem.description = "Output Split String Plugin for fluentd"
|
11
|
+
gem.summary = "Output Split String Plugin for fluentd"
|
12
|
+
gem.licenses = ["MIT"]
|
13
|
+
gem.has_rdoc = false
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "fluentd"
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Fluent
|
2
|
+
class SplitOutput < Output
|
3
|
+
Fluent::Plugin.register_output('split', self)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
config_param :output_tag, :string
|
10
|
+
config_param :output_key, :string
|
11
|
+
config_param :format, :string, :default => "csv"
|
12
|
+
config_param :key_name, :string
|
13
|
+
config_param :keep_keys, :string, :default => ""
|
14
|
+
|
15
|
+
def configure(conf)
|
16
|
+
super
|
17
|
+
@keep_keys_array = @keep_keys.split(",")
|
18
|
+
if @format == "csv"
|
19
|
+
@separator = ','
|
20
|
+
elsif @format == "tsv"
|
21
|
+
@separator = '\t'
|
22
|
+
elsif @format == "space"
|
23
|
+
@separator = ' '
|
24
|
+
else
|
25
|
+
@separator = @format
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def emit(tag, es, chain)
|
30
|
+
es.each { |time, record|
|
31
|
+
record[@key_name].split(@separator).each{|item|
|
32
|
+
result = {@output_key => item}
|
33
|
+
record.each {|key,value|
|
34
|
+
result[key] = value if @keep_keys_array.include?(key)
|
35
|
+
}
|
36
|
+
Engine.emit(output_tag, time, result)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
chain.next
|
40
|
+
rescue => e
|
41
|
+
$log.warn e.message
|
42
|
+
$log.warn e.backtrace.join(', ')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative 'spec_helper'
|
3
|
+
|
4
|
+
describe Fluent::SplitOutput do
|
5
|
+
before { Fluent::Test.setup }
|
6
|
+
CONFIG = %[
|
7
|
+
type split
|
8
|
+
output_tag split.keyword
|
9
|
+
output_key keyword
|
10
|
+
format csv
|
11
|
+
key_name keywords
|
12
|
+
keep_keys object_type
|
13
|
+
]
|
14
|
+
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.setup(:default, :test)
|
5
|
+
Bundler.require(:default, :test)
|
6
|
+
|
7
|
+
require 'fluent/test'
|
8
|
+
require 'rspec'
|
9
|
+
require 'pry'
|
10
|
+
|
11
|
+
$TESTING=true
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
13
|
+
require 'fluent/plugin/out_split'
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-split
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hiroshi Toyama
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-01 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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Output Split String Plugin for fluentd
|
28
|
+
email: toyama0919@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
34
|
+
- ".rspec"
|
35
|
+
- ".travis.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- fluent-plugin-split.gemspec
|
42
|
+
- lib/fluent/plugin/out_split.rb
|
43
|
+
- spec/out_split_spec.rb
|
44
|
+
- spec/spec_helper.rb
|
45
|
+
homepage: https://github.com/toyama0919/fluent-plugin-split
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.2.0.rc.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Output Split String Plugin for fluentd
|
69
|
+
test_files:
|
70
|
+
- spec/out_split_spec.rb
|
71
|
+
- spec/spec_helper.rb
|