fluent-plugin-sampling-filter 0.1.2 → 0.1.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3bc7e8e8abf7ba9ab745bd507bda6cba1d6b0eb3
4
+ data.tar.gz: 73e288aaf2416e2c120ee5009ca05497e4f4896d
5
+ SHA512:
6
+ metadata.gz: f17bcc17d7d9b8593e7c6d85c8ec5fa567484625ae43c9fd9e8cb1de0f3c0234151f46643e3645cff1457ddea98763601a87f3bd98755869a073a0c7e53fbb7b
7
+ data.tar.gz: 477ed760d0a90510ab1bbc8694fb8da4fd2be91a58668826a79d261b3e312f29b25b77b628f6603e2c8425cad1b462ec854395f7e334bb2e2824af203760c57d
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ .DS_Store
31
+
32
+ # For TextMate
33
+ *.tmproj
34
+ tmtags
35
+
36
+ # For emacs:
37
+ *~
38
+ \#*
39
+ .\#*
40
+
41
+ # For vim:
42
+ *.swp
43
+
44
+ # For redcar:
45
+ #.redcar
46
+
47
+ # For rubinius:
48
+ #*.rbc
49
+
50
+ Gemfile.lock
51
+ vendor
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,16 +1,2 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "shoulda", ">= 0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.6.4"
12
- gem "simplecov", ">= 0"
13
- gem "rdoc"
14
- end
15
-
16
- gem "fluentd"
1
+ source "https://rubygems.org"
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # fluent-plugin-sampling-filter
2
+
3
+ ## Component
4
+
5
+ ### SamplingFilterOutput
6
+
7
+ This is a [Fluentd](http://fluentd.org) plugin to sample matching messages to analyse and report messages behavior and emit sampled messages with modified tag.
8
+
9
+ * sampling rate per tags, or for all
10
+ * remove_prefix of tags for input messages, and add_prefix of tags for output(sampled) messages
11
+
12
+ ## Configuration
13
+
14
+ ### SamplingFilterOutput
15
+
16
+ Pickup 1/10 messages about each tags(default: `sample_unit tag`), and add tag prefix `sampled`.
17
+
18
+ <match **>
19
+ type sampling_filter
20
+ interval 10
21
+ add_prefix sampled
22
+ </match>
23
+
24
+ <match sampled.**>
25
+ # output configurations where to send sampled messages
26
+ </match>
27
+
28
+ Pickup 1/100 messages of all matched messages, and modify tags from `input.**` to `output.**`
29
+
30
+ <match input.**>
31
+ type sampling_filter
32
+ interval 100
33
+ sample_unit all
34
+ remove_prefix input
35
+ add_prefix output
36
+ </match>
37
+
38
+ <match sampled.**>
39
+ # output configurations where to send sampled messages
40
+ </match>
41
+
42
+ ## TODO
43
+
44
+ * consider what to do next
45
+ * patches welcome!
46
+
47
+ ## Copyright
48
+
49
+ * Copyright
50
+ * Copyright (c) 2012- TAGOMORI Satoshi (tagomoris)
51
+ * License
52
+ * Apache License, Version 2.0
data/Rakefile CHANGED
@@ -1,29 +1,5 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "fluent-plugin-sampling-filter"
18
- gem.homepage = "http://github.com/tagomoris/fluent-plugin-sampling-filter"
19
- # gem.license = "MIT"
20
- gem.summary = %Q{fluentd plugin to pickup sample data from matched massages}
21
- gem.description = %Q{fluentd plugin to pickup sample data from matched massages}
22
- gem.email = "tagomoris@gmail.com"
23
- gem.authors = ["TAGOMORI Satoshi"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
27
3
 
28
4
  require 'rake/testtask'
29
5
  Rake::TestTask.new(:test) do |test|
@@ -32,22 +8,4 @@ Rake::TestTask.new(:test) do |test|
32
8
  test.verbose = true
33
9
  end
34
10
 
35
- # require 'rcov/rcovtask'
36
- # Rcov::RcovTask.new do |test|
37
- # test.libs << 'test'
38
- # test.pattern = 'test/**/test_*.rb'
39
- # test.verbose = true
40
- # test.rcov_opts << '--exclude "gems/*"'
41
- # end
42
-
43
11
  task :default => :test
44
-
45
- require 'rdoc/task'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "fluent-plugin-sampling-filter #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
@@ -1,64 +1,20 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = "fluent-plugin-sampling-filter"
8
- s.version = "0.1.2"
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "fluent-plugin-sampling-filter"
5
+ gem.version = "0.1.3"
6
+ gem.authors = ["TAGOMORI Satoshi"]
7
+ gem.email = ["tagomoris@gmail.com"]
8
+ gem.description = %q{fluentd plugin to pickup sample data from matched massages}
9
+ gem.summary = %q{fluentd plugin to pickup sample data from matched massages}
10
+ gem.homepage = "https://github.com/tagomoris/fluent-plugin-sampling-filter"
11
+ gem.license = "APLv2"
9
12
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["TAGOMORI Satoshi"]
12
- s.date = "2012-08-08"
13
- s.description = "fluentd plugin to pickup sample data from matched massages"
14
- s.email = "tagomoris@gmail.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "AUTHORS",
22
- "Gemfile",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "fluent-plugin-sampling-filter.gemspec",
28
- "lib/fluent/plugin/out_sampling_filter.rb",
29
- "test/helper.rb",
30
- "test/plugin/test_out_sampling_filter.rb"
31
- ]
32
- s.homepage = "http://github.com/tagomoris/fluent-plugin-sampling-filter"
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = "1.8.21"
35
- s.summary = "fluentd plugin to pickup sample data from matched massages"
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
36
17
 
37
- if s.respond_to? :specification_version then
38
- s.specification_version = 3
39
-
40
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- s.add_runtime_dependency(%q<fluentd>, [">= 0"])
42
- s.add_development_dependency(%q<shoulda>, [">= 0"])
43
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
44
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
45
- s.add_development_dependency(%q<simplecov>, [">= 0"])
46
- s.add_development_dependency(%q<rdoc>, [">= 0"])
47
- else
48
- s.add_dependency(%q<fluentd>, [">= 0"])
49
- s.add_dependency(%q<shoulda>, [">= 0"])
50
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
52
- s.add_dependency(%q<simplecov>, [">= 0"])
53
- s.add_dependency(%q<rdoc>, [">= 0"])
54
- end
55
- else
56
- s.add_dependency(%q<fluentd>, [">= 0"])
57
- s.add_dependency(%q<shoulda>, [">= 0"])
58
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
60
- s.add_dependency(%q<simplecov>, [">= 0"])
61
- s.add_dependency(%q<rdoc>, [">= 0"])
62
- end
18
+ gem.add_development_dependency "rake"
19
+ gem.add_runtime_dependency "fluentd"
63
20
  end
64
-
@@ -7,14 +7,21 @@ class Fluent::SamplingFilterOutput < Fluent::Output
7
7
  config_param :add_prefix, :string, :default => 'sampled'
8
8
  config_param :minimum_rate_per_min, :integer, :default => nil
9
9
 
10
+ # Define `log` method for v0.10.42 or earlier
11
+ unless method_defined?(:log)
12
+ define_method("log") { $log }
13
+ end
14
+
10
15
  def configure(conf)
11
16
  super
12
17
 
13
18
  if @remove_prefix
14
19
  @removed_prefix_string = @remove_prefix + '.'
15
20
  @removed_length = @removed_prefix_string.length
21
+ elsif @add_prefix.empty?
22
+ raise Fluent::ConfigError, "either of 'add_prefix' or 'remove_prefix' must be specified"
16
23
  end
17
- @added_prefix_string = @add_prefix + '.'
24
+ @added_prefix_string = @add_prefix + '.' unless @add_prefix.empty?
18
25
 
19
26
  @sample_unit = case @sample_unit
20
27
  when 'tag'
@@ -33,11 +40,11 @@ class Fluent::SamplingFilterOutput < Fluent::Output
33
40
  ( (tag.start_with?(@removed_prefix_string) and tag.length > @removed_length) or tag == @remove_prefix)
34
41
  tag = tag[@removed_length..-1]
35
42
  end
36
- tag = if tag.length > 0
37
- @added_prefix_string + tag
38
- else
39
- @add_prefix
40
- end
43
+ if tag.length > 0
44
+ tag = @added_prefix_string + tag if @added_prefix_string
45
+ else
46
+ tag = @add_prefix
47
+ end
41
48
 
42
49
  time_record_pairs.each {|t,r|
43
50
  Fluent::Engine.emit(tag, t, r)
data/test/helper.rb CHANGED
@@ -8,7 +8,6 @@ rescue Bundler::BundlerError => e
8
8
  exit e.status_code
9
9
  end
10
10
  require 'test/unit'
11
- require 'shoulda'
12
11
 
13
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -144,4 +144,22 @@ minimum_rate_per_min 10
144
144
  assert_equal ((1..10).map(&:to_i)+[20,30,40,50,60,70,80,90,100]+(101..110).map(&:to_i)+[120,130]), emits.map{|t,time,r| r['times']}
145
145
  assert_equal (['x']*19 + ['y']*12), emits.map{|t,time,r| r['data']}
146
146
  end
147
+
148
+ def test_without_add_prefix_but_remove_prefix
149
+ config = %[
150
+ interval 10
151
+ add_prefix # empty
152
+ remove_prefix input
153
+ ]
154
+ d = create_driver(config, 'input.hoge3')
155
+ time = Time.parse("2012-01-02 13:14:15").to_i
156
+ d.run do
157
+ (1..100).each do |t|
158
+ d.emit({'times' => t, 'data' => 'x'})
159
+ end
160
+ end
161
+ emits = d.emits
162
+ assert_equal 10, emits.length
163
+ assert_equal 'hoge3', emits[0][0]
164
+ end
147
165
  end
metadata CHANGED
@@ -1,156 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sampling-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - TAGOMORI Satoshi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-08 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: fluentd
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: shoulda
14
+ name: rake
32
15
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
16
  requirements:
35
- - - ! '>='
17
+ - - ">="
36
18
  - !ruby/object:Gem::Version
37
19
  version: '0'
38
20
  type: :development
39
21
  prerelease: false
40
22
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
23
  requirements:
43
- - - ! '>='
24
+ - - ">="
44
25
  - !ruby/object:Gem::Version
45
26
  version: '0'
46
27
  - !ruby/object:Gem::Dependency
47
- name: bundler
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 1.0.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 1.0.0
62
- - !ruby/object:Gem::Dependency
63
- name: jeweler
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.6.4
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.6.4
78
- - !ruby/object:Gem::Dependency
79
- name: simplecov
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rdoc
28
+ name: fluentd
96
29
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
30
  requirements:
99
- - - ! '>='
31
+ - - ">="
100
32
  - !ruby/object:Gem::Version
101
33
  version: '0'
102
- type: :development
34
+ type: :runtime
103
35
  prerelease: false
104
36
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
37
  requirements:
107
- - - ! '>='
38
+ - - ">="
108
39
  - !ruby/object:Gem::Version
109
40
  version: '0'
110
41
  description: fluentd plugin to pickup sample data from matched massages
111
- email: tagomoris@gmail.com
42
+ email:
43
+ - tagomoris@gmail.com
112
44
  executables: []
113
45
  extensions: []
114
- extra_rdoc_files:
115
- - LICENSE.txt
116
- - README.rdoc
46
+ extra_rdoc_files: []
117
47
  files:
118
- - .document
48
+ - ".document"
49
+ - ".gitignore"
50
+ - ".travis.yml"
119
51
  - AUTHORS
120
52
  - Gemfile
121
53
  - LICENSE.txt
122
- - README.rdoc
54
+ - README.md
123
55
  - Rakefile
124
- - VERSION
125
56
  - fluent-plugin-sampling-filter.gemspec
126
57
  - lib/fluent/plugin/out_sampling_filter.rb
127
58
  - test/helper.rb
128
59
  - test/plugin/test_out_sampling_filter.rb
129
- homepage: http://github.com/tagomoris/fluent-plugin-sampling-filter
130
- licenses: []
60
+ homepage: https://github.com/tagomoris/fluent-plugin-sampling-filter
61
+ licenses:
62
+ - APLv2
63
+ metadata: {}
131
64
  post_install_message:
132
65
  rdoc_options: []
133
66
  require_paths:
134
67
  - lib
135
68
  required_ruby_version: !ruby/object:Gem::Requirement
136
- none: false
137
69
  requirements:
138
- - - ! '>='
70
+ - - ">="
139
71
  - !ruby/object:Gem::Version
140
72
  version: '0'
141
- segments:
142
- - 0
143
- hash: 2658451737493219281
144
73
  required_rubygems_version: !ruby/object:Gem::Requirement
145
- none: false
146
74
  requirements:
147
- - - ! '>='
75
+ - - ">="
148
76
  - !ruby/object:Gem::Version
149
77
  version: '0'
150
78
  requirements: []
151
79
  rubyforge_project:
152
- rubygems_version: 1.8.21
80
+ rubygems_version: 2.2.2
153
81
  signing_key:
154
- specification_version: 3
82
+ specification_version: 4
155
83
  summary: fluentd plugin to pickup sample data from matched massages
156
- test_files: []
84
+ test_files:
85
+ - test/helper.rb
86
+ - test/plugin/test_out_sampling_filter.rb
data/README.rdoc DELETED
@@ -1,50 +0,0 @@
1
- = fluent-plugin-sampling-filter
2
-
3
- == Component
4
-
5
- === SamplingFilterOutput
6
-
7
- Do sampling from matching messages to analyse and report messages behavior, and emit sampled messages with modified tag.
8
-
9
- - sampling rate per tags, or for all
10
- - remove_prefix of tags for input messages, and add_prefix of tags for output(sampled) messages
11
-
12
- == Configuration
13
-
14
- === SamplingFilterOutput
15
-
16
- Pickup 1/10 messages about each tags(default: 'sample_unit tag'), and add tag prefix 'sampled'.
17
-
18
- <match **>
19
- type sampling_filter
20
- interval 10
21
- add_prefix sampled
22
- </match>
23
-
24
- <match sampled.**>
25
- # output configurations where to send sampled messages
26
- </match>
27
-
28
- Pickup 1/100 messages of all matched messages, and modify tags from input.** to output.**
29
-
30
- <match input.**>
31
- type sampling_filter
32
- interval 100
33
- sample_unit all
34
- remove_prefix input
35
- add_prefix output
36
- </match>
37
-
38
- <match sampled.**>
39
- # output configurations where to send sampled messages
40
- </match>
41
-
42
- == TODO
43
-
44
- - consider what to do next
45
- - patches welcome!
46
-
47
- == Copyright
48
-
49
- Copyright:: Copyright (c) 2012- TAGOMORI Satoshi (tagomoris)
50
- License:: Apache License, Version 2.0
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.2