fluent-plugin-reemit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b0bd1173d45c889368133e764d37dfa6ad415a6c
4
+ data.tar.gz: fe491e0d1d1fd60d4dca49e396c850b2686b4edc
5
+ SHA512:
6
+ metadata.gz: d8c65a9eeb765e59180277440f064e52f34be207d1e184a744ca76f3598967b4d5540af2183681086ba40c597097e85c405c4ea010e7a917502f9818dbcd9ec1
7
+ data.tar.gz: b0cc9a6286c0ec057cf5bb52ecf7e0f97b56aa3b42d21eb5eee3d09081dd5f58ed18665897baf94a49225904a90bacfff48ededbb4ca97566b234ada0aacd6c1
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /*.gem
2
+ ~*
3
+ #*
4
+ *~
5
+ .bundle
6
+ Gemfile.lock
7
+ .rbenv-version
8
+ vendor
9
+ doc/*
10
+ tmp/*
11
+ coverage
12
+ .yardoc
13
+ pkg/
14
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ gemfile:
6
+ - Gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (2014/01/21)
2
+
3
+ First release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Naotoshi SEO
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,59 @@
1
+ # fluent-plugin-reemit
2
+
3
+ [![Build Status](https://secure.travis-ci.org/sonots/fluent-plugin-reemit.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-reemit)
4
+
5
+ Fluentd plugin to re-emit messages avoiding infinity match loop
6
+
7
+ ## Installation
8
+
9
+ Use RubyGems:
10
+
11
+ gem install fluent-plugin-reemit
12
+
13
+ ## Configuration
14
+
15
+ Example:
16
+
17
+ This example applies [flowcounter](https://github.com/tagomoris/fluent-plugin-flowcounter) plugin for all messages, then re-emit messages.
18
+ But, the re-emitted messages will skip the identical match directive (the first one) to avoid an infinity loop.
19
+
20
+ ```apache
21
+ <match **>
22
+ type copy
23
+ <store>
24
+ type flowcounter
25
+ count_keys *
26
+ </store>
27
+ <store>
28
+ type reemit
29
+ </store>
30
+ </match>
31
+
32
+ <match flowcount>
33
+ type stdout
34
+ </match>
35
+
36
+ <match **>
37
+ type stdout
38
+ </match>
39
+ ```
40
+
41
+ ## Option Parameters
42
+
43
+ None
44
+
45
+ ## ChangeLog
46
+
47
+ See [CHANGELOG.md](CHANGELOG.md) for details.
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create new [Pull Request](../../pull/new/master)
56
+
57
+ ## Copyright
58
+
59
+ Copyright (c) 2013 Naotoshi Seo. 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,20 @@
1
+ <source>
2
+ type gc_stat
3
+ emit_interval 1s
4
+ tag gc_stat
5
+ </source>
6
+
7
+ <match **>
8
+ type copy
9
+ <store>
10
+ type stdout
11
+ </store>
12
+ <store>
13
+ type reemit # re-emitted messages are not absorbed by <match **>
14
+ </store>
15
+ </match>
16
+
17
+ <match **>
18
+ type file
19
+ path gc_stat.txt
20
+ </match>
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "fluent-plugin-reemit"
6
+ gem.version = "0.0.1"
7
+ gem.authors = ["Naotoshi Seo"]
8
+ gem.email = "sonots@gmail.com"
9
+ gem.homepage = "https://github.com/sonots/fluent-plugin-reemit"
10
+ gem.description = "Fluentd plugin to re-emit messages avoiding infinity match loop"
11
+ gem.summary = gem.description
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_dependency "fluentd", "~> 0.10.17"
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "pry"
24
+ gem.add_development_dependency "pry-nav"
25
+ end
@@ -0,0 +1,59 @@
1
+ module Fluent
2
+ class ReemitOutput < Output
3
+ Fluent::Plugin.register_output('reemit', self)
4
+
5
+ def initialize
6
+ super
7
+ @match_cache = {}
8
+ end
9
+
10
+ def configure(conf)
11
+ super
12
+ end
13
+
14
+ def emit(tag, es, chain)
15
+ engine_emit(tag, es)
16
+ chain.next
17
+ rescue => e
18
+ $log.warn "reemit: #{e.class} #{e.message} #{e.backtrace.first}"
19
+ end
20
+
21
+ private
22
+
23
+ # My Engine.emit
24
+ def engine_emit(tag, es)
25
+ target = @match_cache[tag]
26
+ unless target
27
+ target = engine_match(tag) || Fluent::EngineClass::NoMatchMatch.new
28
+ @match_cache[tag] = target
29
+ end
30
+ target.emit(tag, es)
31
+ end
32
+
33
+ # My Engine.match
34
+ def engine_match(tag)
35
+ # @matches.find {|m| m.match(tag) } # original Engine.match
36
+ Engine.matches.find {|m| ignore_self_match(m, tag) }
37
+ end
38
+
39
+ # Currently support only
40
+ #
41
+ # <match foo.bar>
42
+ # type reemit
43
+ # </match>
44
+ #
45
+ # and
46
+ #
47
+ # <match foo.bar>
48
+ # type copy
49
+ # <store>
50
+ # type reemit
51
+ # </store>
52
+ # </match>
53
+ def ignore_self_match(m, tag)
54
+ return false if m.output == self
55
+ return false if m.output.class == CopyOutput and m.output.outputs.include?(self)
56
+ m.match(tag)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: UTF-8
2
+ require_relative 'spec_helper'
3
+
4
+ describe Fluent::ReemitOutput do
5
+ before { Fluent::Test.setup }
6
+ # There is not test driver which suites
7
+ end
@@ -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_reemit'
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-reemit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-21 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.10.17
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.17
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '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: pry-nav
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Fluentd plugin to re-emit messages avoiding infinity match loop
84
+ email: sonots@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - .gitignore
90
+ - .rspec
91
+ - .travis.yml
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - examples/reemit.conf
98
+ - fluent-plugin-reemit.gemspec
99
+ - lib/fluent/plugin/out_reemit.rb
100
+ - spec/out_reemit_spec.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/sonots/fluent-plugin-reemit
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Fluentd plugin to re-emit messages avoiding infinity match loop
126
+ test_files:
127
+ - spec/out_reemit_spec.rb
128
+ - spec/spec_helper.rb