fluent-plugin-add 0.0.1
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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +1 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/fluent-plugin-add.gemspec +23 -0
- data/lib/fluent/plugin/out_add.rb +50 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_add.rb +24 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31221f78814f625582ad157fa0a2dd16e5fa0aad
|
4
|
+
data.tar.gz: c291c3493ff4916127474931979b7db74edf7a20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c60b974102cb5685af42945cf49a0097b7c57ae52915aaa0af0acc68b296512a2b3ac9296b0050d95c373f1c4eb0ac7a97ce9bf418e360bfbfb83247ce76ae6
|
7
|
+
data.tar.gz: 360f0840ea337cc19b2317a8b49bb379b2e49f120ebcb8f94f9724dba5d100362751881dd60b650d01df494c694e83bd35dc93d59e7b1bd4ae4542aa189d7a0c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Copyright (c) 2013 yu-yamada
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Fluent::Plugin::Add
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fluent-plugin-add'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-add
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
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/add/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-add"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.authors = ["yu yamada"]
|
10
|
+
spec.email = ["yu.yamada@outlook.com"]
|
11
|
+
spec.description = %q{Output filter plugin to count messages that matches specified conditions}
|
12
|
+
spec.summary = %q{Output filter plugin to count messages that matches specified conditions}
|
13
|
+
spec.homepage = "https://github.com/yu-yamada/fluent-plugin-add"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pp'
|
2
|
+
class Fluent::AddOutput < Fluent::Output
|
3
|
+
Fluent::Plugin.register_output('add', self)
|
4
|
+
|
5
|
+
config_param :key, :string
|
6
|
+
config_param :value, :string, :default => nil
|
7
|
+
config_param :add_tag_prefix, :string, :default => 'greped'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
|
16
|
+
@key = @key.to_s
|
17
|
+
@value = @value.to_s
|
18
|
+
@tag_prefix = "#{@add_tag_prefix}."
|
19
|
+
@add_hash = Hash.new
|
20
|
+
|
21
|
+
@tag_proc =
|
22
|
+
if @tag_prefix
|
23
|
+
Proc.new {|tag| "#{@tag_prefix}#{tag}" }
|
24
|
+
else
|
25
|
+
Proc.new {|tag| tag }
|
26
|
+
end
|
27
|
+
conf.elements.select {|element|
|
28
|
+
element.name == 'pair'
|
29
|
+
}.each do |pair|
|
30
|
+
pair.each do | k,v|
|
31
|
+
@add_hash[k] = v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def emit(tag, es, chain)
|
37
|
+
emit_tag = @tag_proc.call(tag)
|
38
|
+
|
39
|
+
es.each do |time,record|
|
40
|
+
record[@key] = @value
|
41
|
+
@add_hash.each do |k,v|
|
42
|
+
record[k] = v
|
43
|
+
end
|
44
|
+
Fluent::Engine.emit(emit_tag, time, record)
|
45
|
+
end
|
46
|
+
|
47
|
+
chain.next
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
# require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_add'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AddOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
]
|
10
|
+
# CONFIG = %[
|
11
|
+
# path #{TMP_DIR}/out_file_test
|
12
|
+
# compress gz
|
13
|
+
# utc
|
14
|
+
# ]
|
15
|
+
|
16
|
+
def create_driver(conf = CONFIG, tag='test')
|
17
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::DataCounterOutput, tag).configure(conf)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_configure
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-add
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yu yamada
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-08 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: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Output filter plugin to count messages that matches specified conditions
|
42
|
+
email:
|
43
|
+
- yu.yamada@outlook.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- fluent-plugin-add.gemspec
|
54
|
+
- lib/fluent/plugin/out_add.rb
|
55
|
+
- test/helper.rb
|
56
|
+
- test/plugin/test_out_add.rb
|
57
|
+
homepage: https://github.com/yu-yamada/fluent-plugin-add
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Output filter plugin to count messages that matches specified conditions
|
81
|
+
test_files:
|
82
|
+
- test/helper.rb
|
83
|
+
- test/plugin/test_out_add.rb
|