fluent-plugin-exclude-filter 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d224d756d4f332b9fba270acae1aa53085b107bc
4
+ data.tar.gz: 9aa56ce0b300094ff624da9fba2b60945a3006c8
5
+ SHA512:
6
+ metadata.gz: 5364e081c5a4a5dfbf75e1978247fea3ef277016216c7bc263767fa97f5d6f916b6dd14b9e5e9eef4cc08f599bd595f460430fb10acd43ae68e71872aa182d48
7
+ data.tar.gz: cc125cfd2d6778483219081f32dfe16bbcad3989b43252a9983e7572acc0fe103cfb41456b4096b28dd4007517a152e8bc4c00a2f72cb8c29c77c9d8fb9048fc
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-exclude-filter.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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.
@@ -0,0 +1,11 @@
1
+ # fluent-plugin-exclude-filter, a plugin for [Fluentd](http://fluentd.org)
2
+
3
+ exclude some records.
4
+
5
+ ## Installation
6
+
7
+
8
+ gem install fluent-plugin-exclude-filter
9
+
10
+ ## Copyright
11
+ Copyright (c) 2014 yu-yamada
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-exclude-filter"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["yu yamada"]
9
+ spec.email = ["yu.yamada07@gmail.com"]
10
+ spec.description = %q{Output filter plugin to exclude records}
11
+ spec.summary = %q{Output filter plugin to exclude records}
12
+ spec.homepage = "https://github.com/yu-yamada/fluent-plugin-exclude-filter"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,75 @@
1
+ require 'yaml'
2
+ class Fluent::ExcludeFilterOutput < Fluent::Output
3
+ Fluent::Plugin.register_output('exclude_filter', self)
4
+
5
+ config_param :key, :string, :default => nil
6
+ config_param :value, :string, :default => nil
7
+ config_param :file_path, :string, :default => nil
8
+ config_param :regexp, :bool, :default => false
9
+ config_param :add_tag_prefix, :string, :default => 'exclude'
10
+
11
+ def initialize
12
+ super
13
+ end
14
+
15
+ def configure(conf)
16
+ super
17
+
18
+ @key = @key.to_s
19
+ @value = @value.to_s
20
+ @tag_prefix = "#{@add_tag_prefix}."
21
+
22
+ @tag_proc =
23
+ if @tag_prefix
24
+ Proc.new {|tag| "#{@tag_prefix}#{tag}" }
25
+ else
26
+ Proc.new {|tag| tag }
27
+ end
28
+
29
+ @excludes_yml = nil
30
+ if @file_path
31
+ @excludes_yml = YAML.load_file(@file_path)
32
+ end
33
+ end
34
+
35
+ def emit(tag, es, chain)
36
+ emit_tag = @tag_proc.call(tag)
37
+
38
+ es.each do |time,record|
39
+ if @key && @value
40
+ next if match(@key, @value, record)
41
+ end
42
+ if @excludes_yml
43
+ next if yml_match(record)
44
+ end
45
+
46
+ Fluent::Engine.emit(emit_tag, time, record)
47
+ end
48
+
49
+ chain.next
50
+ end
51
+
52
+ def yml_match(record)
53
+ @excludes_yml.each{|k,v|
54
+ if v.kind_of?(Array)
55
+ v.each{|va|
56
+ if match(k, va, record)
57
+ return true
58
+ end
59
+ }
60
+ else
61
+ if match(k, v, record)
62
+ return true
63
+ end
64
+ end
65
+ }
66
+ return false
67
+ end
68
+ def match(k, v, record)
69
+ if @regexp
70
+ return Regexp.compile(v.to_s).match(record[k])
71
+ else
72
+ return record[k] == v.to_s
73
+ end
74
+ end
75
+ end
File without changes
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-exclude-filter
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: 2014-08-10 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 exclude records
42
+ email:
43
+ - yu.yamada07@gmail.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-exclude-filter.gemspec
54
+ - lib/fluent/plugin/out_exclude_filter.rb
55
+ - test/plugin/test_out_exclude_filter.rb
56
+ homepage: https://github.com/yu-yamada/fluent-plugin-exclude-filter
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.0.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Output filter plugin to exclude records
80
+ test_files:
81
+ - test/plugin/test_out_exclude_filter.rb