fluent-plugin-mongo 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 704336957f5f5ebdec8351e961f38555db15ce16
4
- data.tar.gz: f8dc945869ddf4c3e8125b517757371b86067c3d
3
+ metadata.gz: b4c03c163ad52a2f48b8fa88d69370d4c1ed0810
4
+ data.tar.gz: cf0f26a570dcfaed4c24bde308446b36ba0c2cfd
5
5
  SHA512:
6
- metadata.gz: aad06123bf520927bba1e718efaf297f379c98419ce7dc6d1068d2da9a0b86b40d291b017b2d0dfd1b1cb9fc72e766d7f82884e5f7248790fbce47197612b703
7
- data.tar.gz: 9b18985959ec858e77680ca8bf21037cfb2b62461f427889c03d5166e156617492d8ceda492a1d2598e44f18c30e14d745708c1136d6fe0260808e90ca300959
6
+ metadata.gz: 871f0d9f4880db300354aff08ba51f1a9f07718e01e9b3527ee22c5be107bda3f4ce9e96d7d5ed431a7ed704eb90fe421ba178a357216a1e9070630ff33847dd
7
+ data.tar.gz: 182460bff1536f1997c238537292cbb0a048af93ef74a2393e275b79b0ae969707336d4c3243cdfe50a8f717b3929ac8ab1cffd4b91a0e01c51499985dc035ee
data/.travis.yml CHANGED
@@ -1,9 +1,15 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
- - ruby-head
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - rbx
5
7
 
6
8
  before_script:
7
9
  - git submodule update -i
8
10
 
9
- script: bundle exec rake test
11
+ script: mongod=mongod bundle exec rake test
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: rbx
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ Release 0.7.3 - 2014/03/09
2
+
3
+ * Add replace_dot_in_key_with and replace_dollar_in_key_with parameters to sanitize invalid key
4
+ * Add ssl parameter to enable SSL connection
5
+ * Relax gem version dependency
6
+
7
+
1
8
  Release 0.7.2 - 2014/02/05
2
9
 
3
10
  * Support log_level option
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
- = MongoDB plugin for Fluentd
1
+ = MongoDB plugin for {Fluentd}[http://github.com/fluent/fluentd]
2
2
 
3
- fluent-plugin-mongo provides input and output plugins for {Fluentd}[http://fluentd.org/].
3
+ fluent-plugin-mongo provides input and output plugins for {Fluentd}[http://fluentd.org] ({GitHub}[http://github.com/fluent/fluentd])
4
4
 
5
5
  = Installation
6
6
 
@@ -199,6 +199,21 @@ If you want to exclude some fields from broken data marshaling, use _exclude_bro
199
199
  Specified value is a comma separated keys(e.g. key1,key2,key3).
200
200
  This parameter is useful for excluding shard keys in shard environment.
201
201
 
202
+ === replace_dot_in_key_with and replace_dollar_in_key_with
203
+
204
+ BSON records which include '.' or start with '$' are invalid and they will be stored as broken data to MongoDB. If you want to sanitize keys, you can use _replace_dot_in_key_with_ and _replace_dollar_in_key_with_.
205
+
206
+ <match forward.*>
207
+ ...
208
+ # replace '.' in keys with '__dot__'
209
+ replace_dot_in_key_with __dot__
210
+
211
+ # replace '$' in keys with '__dollar__'
212
+ # Note: This replaces '$' only on first character
213
+ replace_dollar_in_key_with __dollar__
214
+ ...
215
+ </match>
216
+
202
217
  == Buffer size limitation
203
218
 
204
219
  Mongo plugin has the limitation of buffer size.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.3
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-mongo"
6
- gem.description = "MongoDB plugin for Fluent event collector"
6
+ gem.description = "MongoDB plugin for Fluentd"
7
7
  gem.homepage = "https://github.com/fluent/fluent-plugin-mongo"
8
8
  gem.summary = gem.description
9
9
  gem.version = File.read("VERSION").strip
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency "fluentd", "~> 0.10.9"
20
- gem.add_dependency "mongo", "~> 1.8.0"
20
+ gem.add_dependency "mongo", ">= 1.8.0"
21
21
  gem.add_development_dependency "rake", ">= 0.9.2"
22
22
  gem.add_development_dependency "simplecov", ">= 0.5.4"
23
23
  gem.add_development_dependency "rr", ">= 1.0.0"
@@ -19,6 +19,9 @@ module Fluent
19
19
  # To store last ObjectID
20
20
  config_param :id_store_file, :string, :default => nil
21
21
 
22
+ # SSL connection
23
+ config_param :ssl, :bool, :default => false
24
+
22
25
  unless method_defined?(:log)
23
26
  define_method(:log) { $log }
24
27
  end
@@ -27,6 +30,8 @@ module Fluent
27
30
  super
28
31
  require 'mongo'
29
32
  require 'bson'
33
+
34
+ @connection_options = {}
30
35
  end
31
36
 
32
37
  def configure(conf)
@@ -37,6 +42,7 @@ module Fluent
37
42
  end
38
43
 
39
44
  @last_id = @id_store_file ? get_last_id : nil
45
+ @connection_options[:ssl] = @ssl
40
46
 
41
47
  $log.debug "Setup mongo_tail configuration: mode = #{@id_store_file ? 'persistent' : 'non-persistent'}"
42
48
  end
@@ -69,7 +75,7 @@ module Fluent
69
75
 
70
76
  def get_capped_collection
71
77
  begin
72
- db = authenticate(Mongo::Connection.new(@host, @port).db(@database))
78
+ db = authenticate(Mongo::Connection.new(@host, @port, @connection_options).db(@database))
73
79
  raise ConfigError, "'#{@database}.#{@collection}' not found: node = #{@host}:#{@port}" unless db.collection_names.include?(@collection)
74
80
  collection = db.collection(@collection)
75
81
  raise ConfigError, "'#{@database}.#{@collection}' is not capped: node = #{@host}:#{@port}" unless collection.capped?
@@ -19,11 +19,16 @@ module Fluent
19
19
  config_param :disable_collection_check, :bool, :default => nil
20
20
  config_param :exclude_broken_fields, :string, :default => nil
21
21
  config_param :write_concern, :integer, :default => nil
22
+ config_param :replace_dot_in_key_with, :string, :default => nil
23
+ config_param :replace_dollar_in_key_with, :string, :default => nil
22
24
 
23
25
  # tag mapping mode
24
26
  config_param :tag_mapped, :bool, :default => false
25
27
  config_param :remove_tag_prefix, :string, :default => nil
26
28
 
29
+ # SSL connection
30
+ config_param :ssl, :bool, :default => false
31
+
27
32
  attr_reader :collection_options, :connection_options
28
33
 
29
34
  unless method_defined?(:log)
@@ -65,6 +70,7 @@ module Fluent
65
70
  end
66
71
 
67
72
  @connection_options[:w] = @write_concern unless @write_concern.nil?
73
+ @connection_options[:ssl] = @ssl
68
74
 
69
75
  # MongoDB uses BSON's Date for time.
70
76
  def @timef.format_nocache(time)
@@ -116,6 +122,17 @@ module Fluent
116
122
 
117
123
  def operate(collection, records)
118
124
  begin
125
+ if @replace_dot_in_key_with
126
+ records.map! do |r|
127
+ replace_key_of_hash(r, ".", @replace_dot_in_key_with)
128
+ end
129
+ end
130
+ if @replace_dollar_in_key_with
131
+ records.map! do |r|
132
+ replace_key_of_hash(r, /^\$/, @replace_dollar_in_key_with)
133
+ end
134
+ end
135
+
119
136
  record_ids, error_records = collection.insert(records, INSERT_ARGUMENT)
120
137
  if !@ignore_invalid_record and error_records.size > 0
121
138
  operate_invalid_records(collection, error_records)
@@ -235,5 +252,19 @@ module Fluent
235
252
 
236
253
  version
237
254
  end
255
+
256
+ def replace_key_of_hash(hash, pattern, replacement)
257
+ result = Hash.new
258
+ hash.each_pair do |k, v|
259
+ k = k.gsub(pattern, replacement)
260
+
261
+ if v.is_a?(Hash)
262
+ result[k] = replace_key_of_hash(v, pattern, replacement)
263
+ else
264
+ result[k] = (v.dup rescue v)
265
+ end
266
+ end
267
+ result
268
+ end
238
269
  end
239
270
  end
@@ -51,7 +51,7 @@ class MongoOutputTest < Test::Unit::TestCase
51
51
  assert_equal('localhost', d.instance.host)
52
52
  assert_equal(@@mongod_port, d.instance.port)
53
53
  assert_equal({:capped => true, :size => 100}, d.instance.collection_options)
54
- assert(d.instance.connection_options.empty?)
54
+ assert_equal({:ssl => false}, d.instance.connection_options)
55
55
  # buffer_chunk_limit moved from configure to start
56
56
  # I will move this test to correct space after BufferedOutputTestDriver supports start method invoking
57
57
  # assert_equal(Fluent::MongoOutput::LIMIT_BEFORE_v1_8, d.instance.instance_variable_get(:@buffer).buffer_chunk_limit)
@@ -62,7 +62,15 @@ class MongoOutputTest < Test::Unit::TestCase
62
62
  write_concern 2
63
63
  ])
64
64
 
65
- assert_equal({:w => 2}, d.instance.connection_options)
65
+ assert_equal({:w => 2, :ssl => false}, d.instance.connection_options)
66
+ end
67
+
68
+ def test_configure_with_ssl
69
+ d = create_driver(default_config + %[
70
+ ssl true
71
+ ])
72
+
73
+ assert_equal({:ssl => true}, d.instance.connection_options)
66
74
  end
67
75
 
68
76
  def test_format
@@ -120,6 +128,26 @@ class MongoOutputTest < Test::Unit::TestCase
120
128
  time
121
129
  end
122
130
 
131
+ def test_write_with_invalid_recoreds_with_keys_containing_dot_and_dollar
132
+ d = create_driver(default_config + %[
133
+ replace_dot_in_key_with _dot_
134
+ replace_dollar_in_key_with _dollar_
135
+ ])
136
+
137
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
138
+ d.emit({
139
+ "foo.bar" => {
140
+ "$foo$bar" => "baz"
141
+ }
142
+ }, time)
143
+ d.run
144
+
145
+ documents = get_documents
146
+ assert_equal(1, documents.size)
147
+ assert_equal("baz", documents[0]["foo_dot_bar"]["_dollar_foo$bar"])
148
+ assert_equal(0, documents.select { |e| e.has_key?(Fluent::MongoOutput::BROKEN_DATA_KEY)}.size)
149
+ end
150
+
123
151
  def test_write_with_invalid_recoreds
124
152
  d = create_driver
125
153
  t = emit_documents(d)
@@ -229,5 +257,6 @@ class MongoReplOutputTest < MongoOutputTest
229
257
  assert_equal(build_seeds(3), d.instance.nodes)
230
258
  assert_equal(45, d.instance.num_retries)
231
259
  assert_equal({:capped => true, :size => 100}, d.instance.collection_options)
260
+ assert_equal({:ssl => false}, d.instance.connection_options)
232
261
  end
233
262
  end
metadata CHANGED
@@ -1,95 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.10.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.10.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongo
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.9.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.5.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.5.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.0.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.0.0
83
- description: MongoDB plugin for Fluent event collector
83
+ description: MongoDB plugin for Fluentd
84
84
  email: repeatedly@gmail.com
85
85
  executables:
86
86
  - mongo-tail
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .gitmodules
92
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
93
92
  - AUTHORS
94
93
  - ChangeLog
95
94
  - Gemfile
@@ -119,20 +118,20 @@ require_paths:
119
118
  - lib
120
119
  required_ruby_version: !ruby/object:Gem::Requirement
121
120
  requirements:
122
- - - '>='
121
+ - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
124
  required_rubygems_version: !ruby/object:Gem::Requirement
126
125
  requirements:
127
- - - '>='
126
+ - - ">="
128
127
  - !ruby/object:Gem::Version
129
128
  version: '0'
130
129
  requirements: []
131
130
  rubyforge_project:
132
- rubygems_version: 2.0.2
131
+ rubygems_version: 2.2.0
133
132
  signing_key:
134
133
  specification_version: 4
135
- summary: MongoDB plugin for Fluent event collector
134
+ summary: MongoDB plugin for Fluentd
136
135
  test_files:
137
136
  - test/plugin/in_mongo_tail.rb
138
137
  - test/plugin/out_mongo.rb
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "vendor/fluentd"]
2
- path = vendor/fluentd
3
- url = git://github.com/fluent/fluentd.git