fluent-plugin-script_append 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/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/fluent-plugin-script_append.gemspec +29 -0
- data/lib/fluent-plugin-script_append.rb +1 -0
- data/lib/fluent/plugin/out_script_append.rb +57 -0
- data/lib/fluent/plugin/script_append/version.rb +7 -0
- data/test/helper.rb +19 -0
- data/test/plugin/test_out_script_append.rb +42 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27280a3d62cd0c8ceeb6e9f548bc5fa1ef5b4ad1
|
4
|
+
data.tar.gz: e34fd0d9a34b70de1d56843593b8b4b2be377992
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 741ce22c7fba57d85f4874d5b59fcbdda8cc68f5fb1b8a7329e58cd8c8ebd39c1042f9b47926b7e0f55c0801f40e4583e1e140d11955930c807c11d7835a4fac
|
7
|
+
data.tar.gz: 6f00de3e9a025ba1ebb251df249d1126d6893e00f26aeac485c34e6155555df5dddc20c9c3dcd8e9719d8a5a8de210d1a427d8771f6c4fd82e8179e653a8dd37
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Uchio KONDO
|
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,31 @@
|
|
1
|
+
# Fluent::Plugin::ScriptAppend
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluent-plugin-script_append'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluent-plugin-script_append
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-script_append/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluent/plugin/script_append/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-script_append"
|
8
|
+
spec.version = Fluent::Plugin::ScriptAppend::VERSION
|
9
|
+
spec.authors = ["Uchio KONDO"]
|
10
|
+
spec.email = ["udzura@udzura.jp"]
|
11
|
+
spec.summary = %q{A fluent plugin to add script-run result to existing json data}
|
12
|
+
spec.description = %q{A fluent plugin to add script-run result to existing json data}
|
13
|
+
spec.homepage = "https://github.com/udzura/fluent-plugin-script_append"
|
14
|
+
spec.license = "Apache 2.0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "fluentd"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "test-unit", ">= 3"
|
27
|
+
spec.add_development_dependency "test-unit-rr"
|
28
|
+
spec.add_development_dependency "test-unit-power_assert"
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'fluent/plugin/out_script_append'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'fluent/plugin/script_append/version'
|
2
|
+
|
3
|
+
class Fluent::ScriptAppendOutput < Fluent::Output
|
4
|
+
|
5
|
+
config_param :key, :string, :default => nil
|
6
|
+
config_param :language, :string, :default => 'ruby'
|
7
|
+
config_param :run_script, :string, :default => ''
|
8
|
+
config_param :record_var_name, :string, :default => 'record'
|
9
|
+
config_param :new_tag, :string, :default => nil
|
10
|
+
config_param :prefix, :string, :default => nil
|
11
|
+
|
12
|
+
def configure(conf)
|
13
|
+
super
|
14
|
+
ensure_param_set!(:key, @key)
|
15
|
+
ensure_param_set!(:run_script, @run_script)
|
16
|
+
ensure_param_set!("new_tag or prefix", (@new_tag or @prefix))
|
17
|
+
|
18
|
+
@script_runner = Object.new
|
19
|
+
|
20
|
+
# TODO multiple script language support
|
21
|
+
if @language != 'ruby'
|
22
|
+
warn "Plugin out_script_append would not accept 'language' value other than 'ruby'. Ignoring."
|
23
|
+
end
|
24
|
+
|
25
|
+
eval <<-RUBY
|
26
|
+
def @script_runner.run(#{@record_var_name})
|
27
|
+
#{@run_script}
|
28
|
+
end
|
29
|
+
RUBY
|
30
|
+
end
|
31
|
+
|
32
|
+
def emit(tag, event_stream, chain)
|
33
|
+
event_stream.each do |time, record|
|
34
|
+
rewrited_tag = get_new_tag(tag)
|
35
|
+
record[@key] = @script_runner.run(record)
|
36
|
+
Fluent::Engine.emit(rewrited_tag, time, record)
|
37
|
+
end
|
38
|
+
chain.next
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def get_new_tag(tag)
|
43
|
+
if @new_tag
|
44
|
+
@new_tag
|
45
|
+
elsif @prefix
|
46
|
+
[@prefix, tag].join('.')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def ensure_param_set!(name, value)
|
51
|
+
unless value
|
52
|
+
raise "#{name} must be set"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Fluent::Plugin.register_output('script_append', self)
|
57
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'test/unit/rr'
|
3
|
+
require 'test/unit/power_assert'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
require 'fluent/test'
|
9
|
+
|
10
|
+
unless ENV.has_key?('VERBOSE')
|
11
|
+
nulllogger = Object.new
|
12
|
+
nulllogger.instance_eval {|obj|
|
13
|
+
def method_missing(method, *args)
|
14
|
+
# pass
|
15
|
+
end
|
16
|
+
}
|
17
|
+
$log = nulllogger
|
18
|
+
end
|
19
|
+
require 'fluent/plugin/out_script_append'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ScriptAppendOutputTest < Test::Unit::TestCase
|
4
|
+
def create_driver(conf ,tag='test')
|
5
|
+
Fluent::Test::OutputTestDriver.new(Fluent::ScriptAppendOutput, tag).configure(conf)
|
6
|
+
end
|
7
|
+
|
8
|
+
setup do
|
9
|
+
Fluent::Test.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
CONFIG_DEFAULT = <<-FLUENTD
|
13
|
+
key sample
|
14
|
+
language ruby
|
15
|
+
run_script "Hello, World"
|
16
|
+
new_tag test.result
|
17
|
+
FLUENTD
|
18
|
+
|
19
|
+
test 'configure' do
|
20
|
+
d = create_driver CONFIG_DEFAULT
|
21
|
+
assert_equal "sample", d.instance.config['key']
|
22
|
+
assert_equal '"Hello, World"', d.instance.config['run_script']
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'appends a result' do
|
26
|
+
config = <<-FLUENTD
|
27
|
+
key sample
|
28
|
+
language ruby
|
29
|
+
run_script "Hello, World"
|
30
|
+
new_tag test.result
|
31
|
+
FLUENTD
|
32
|
+
|
33
|
+
d = create_driver CONFIG_DEFAULT, 'input.access'
|
34
|
+
d.run do
|
35
|
+
d.emit({'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
|
36
|
+
end
|
37
|
+
|
38
|
+
emits = d.emits
|
39
|
+
assert_equal 'test.result', emits[0][0]
|
40
|
+
assert_equal 'Hello, World', emits[0][2]['sample']
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-script_append
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Uchio KONDO
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-26 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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
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: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
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
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: test-unit-power_assert
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A fluent plugin to add script-run result to existing json data
|
112
|
+
email:
|
113
|
+
- udzura@udzura.jp
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- fluent-plugin-script_append.gemspec
|
124
|
+
- lib/fluent-plugin-script_append.rb
|
125
|
+
- lib/fluent/plugin/out_script_append.rb
|
126
|
+
- lib/fluent/plugin/script_append/version.rb
|
127
|
+
- test/helper.rb
|
128
|
+
- test/plugin/test_out_script_append.rb
|
129
|
+
homepage: https://github.com/udzura/fluent-plugin-script_append
|
130
|
+
licenses:
|
131
|
+
- Apache 2.0
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.0.14
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: A fluent plugin to add script-run result to existing json data
|
153
|
+
test_files:
|
154
|
+
- test/helper.rb
|
155
|
+
- test/plugin/test_out_script_append.rb
|