fluent-plugin-mongo 1.6.1 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a7505d5d82e1fcf8aa0625efa3bd19f68d7ddd6a9ec8ef75050d5aba1b663a1
4
- data.tar.gz: a0efb583886eb8e8880881d3727dd61e6e2d19c3d2a3d34e4e5d94f0d843b3c3
3
+ metadata.gz: 4b6ccaa707cc9ac56e75260f5482ae641a07b9492bfdd897e37c4f28b3cb6d9a
4
+ data.tar.gz: abfa43c69e8565a83681f68dc6b390b84895e5939a985cb9403cb749f1275b55
5
5
  SHA512:
6
- metadata.gz: c26d8de1f5c46fbeec69a871fcd26ac83969b58b49990a458f8a25eff830a2b35197267a002d657d3ae751aced56d5637ed1fbc394635e2c59886b4ba2fbe82f
7
- data.tar.gz: 4a33374071ca219f56bb3be9132c1e05d3c2bf1c4018d769fbf2cb7ea61b4eb8f0cabbb6e85baceea9dfcd44c80bc11e7fce75356abe7846fdb6b6a150d082b3
6
+ metadata.gz: c881203d25fbbbec76d3dbbbc3ed9c92484552e0ea9869827b54d96a1ce7fb303cb49b1162f6fc66e3aa284fc6a07895202efe9a3cb3e811be3476c2dfe051cc
7
+ data.tar.gz: f447183d0f51b61d31f6b913242df7d6719d0f32efa79b23dfd4ea4f404fb30468ce29c8de68be0d45250360cc98829b341bc9040c15ae6fff9f21618b4f59cc
@@ -0,0 +1,72 @@
1
+ name: Bug Report
2
+ description: Create a report with a procedure for reproducing the bug
3
+ labels: "waiting-for-triage"
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Please check the [README](https://github.com/fluent/fluent-plugin-mongo/blob/master/README.rdoc) first. To help us investigate the problem, please provide the following information.
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: Describe the bug
13
+ description: A clear and concise description of what the bug is
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: reproduce
18
+ attributes:
19
+ label: To Reproduce
20
+ description: Steps to reproduce the behavior
21
+ validations:
22
+ required: true
23
+ - type: textarea
24
+ id: expected
25
+ attributes:
26
+ label: Expected behavior
27
+ description: A clear and concise description of what you expected to happen
28
+ validations:
29
+ required: true
30
+ - type: textarea
31
+ id: environment
32
+ attributes:
33
+ label: Your Environment
34
+ description: |
35
+ - Fluentd or td-agent version: `fluentd --version` or `td-agent --version`
36
+ - Operating system: `cat /etc/os-release`
37
+ - Kernel version: `uname -r`
38
+
39
+ Tip: If you hit the problem with older fluentd version, try latest version first.
40
+ value: |
41
+ - Fluentd version:
42
+ - TD Agent/Fluent Package version:
43
+ - fluent-plugin-mongo version:
44
+ - mongo version:
45
+ - Operating system:
46
+ - Kernel version:
47
+ render: markdown
48
+ validations:
49
+ required: true
50
+ - type: textarea
51
+ id: configuration
52
+ attributes:
53
+ label: Your Configuration
54
+ description: |
55
+ Write your configuration here. Minimum reproducible fluentd.conf is recommended.
56
+ validations:
57
+ required: true
58
+ - type: textarea
59
+ id: logs
60
+ attributes:
61
+ label: Your Error Log
62
+ description: Write your ALL error log here
63
+ render: shell
64
+ validations:
65
+ required: true
66
+ - type: textarea
67
+ id: addtional-context
68
+ attributes:
69
+ label: Additional context
70
+ description: Add any other context about the problem here.
71
+ validations:
72
+ required: false
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Ask a Question
4
+ url: https://discuss.fluentd.org/
5
+ about: I have questions about fluent-plugin-mongo. Please ask and answer questions at https://discuss.fluentd.org/.
@@ -0,0 +1,38 @@
1
+ name: Feature request
2
+ description: Suggest an idea for this project
3
+ labels: "waiting-for-triage"
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Please check the [README](https://github.com/fluent/fluent-plugin-mongo/blob/master/README.rdoc) first. To help us understand the request, please provide the following information.
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: Is your feature request related to a problem? Please describe.
13
+ description: |
14
+ A clear and concise description of what the problem is.
15
+ Ex. I'm always frustrated when [...]
16
+ validations:
17
+ required: true
18
+ - type: textarea
19
+ id: solution
20
+ attributes:
21
+ label: Describe the solution you'd like
22
+ description: A clear and concise description of what you want to happen.
23
+ validations:
24
+ required: true
25
+ - type: textarea
26
+ id: alternative
27
+ attributes:
28
+ label: Describe alternatives you've considered
29
+ description: A clear and concise description of any alternative solutions or features you've considered.
30
+ validations:
31
+ required: true
32
+ - type: textarea
33
+ id: addtional-context
34
+ attributes:
35
+ label: Additional context
36
+ description: Add any other context or screenshots about the feature request here.
37
+ validations:
38
+ required: false
@@ -3,4 +3,4 @@ updates:
3
3
  - package-ecosystem: 'github-actions'
4
4
  directory: '/'
5
5
  schedule:
6
- interval: 'weekly'
6
+ interval: 'monthly'
@@ -0,0 +1,24 @@
1
+ name: Add bugs to fluent project
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ add-to-project:
10
+ name: Add issue to project
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Generate token
14
+ id: generate_token
15
+ uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
16
+ with:
17
+ app-id: ${{ secrets.PROJECT_APP_ID }}
18
+ private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
19
+ owner: fluent
20
+ - uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
21
+ with:
22
+ project-url: https://github.com/orgs/fluent/projects/4
23
+ github-token: ${{ steps.generate_token.outputs.token }}
24
+ labeled: waiting-for-triage
@@ -4,40 +4,34 @@ on:
4
4
  branches: [master]
5
5
  pull_request:
6
6
  branches: [master]
7
+ schedule:
8
+ - cron: '0 0 1 * *'
7
9
  jobs:
10
+ ruby-versions:
11
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
+ with:
13
+ engine: cruby
14
+ min_version: 2.7
8
15
  build:
16
+ needs: ruby-versions
9
17
  runs-on: ${{ matrix.os }}
10
- continue-on-error: ${{ matrix.experimental }}
18
+ continue-on-error: ${{ matrix.ruby == 'head' }}
11
19
  strategy:
12
20
  fail-fast: false
13
21
  matrix:
14
- ruby: [ '4.0', '3.4', '3.3', '3.2', '3.1', '3.0', '2.7' ]
15
- mongodb-version: ['5.0', '4.4', '4.2']
22
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
23
+ mongodb-version: ['8.0', '7.0', '6.0', '5.0', '4.4', '4.2']
16
24
  os:
17
25
  - ubuntu-latest
18
- experimental: [false]
19
- include:
20
- - ruby: head
21
- os: ubuntu-latest
22
- experimental: true
23
- mongodb-version: '4.0'
24
- - ruby: head
25
- os: ubuntu-latest
26
- experimental: true
27
- mongodb-version: '4.2'
28
- - ruby: head
29
- os: ubuntu-latest
30
- experimental: true
31
- mongodb-version: '4.4'
32
26
 
33
27
  name: Ruby ${{ matrix.ruby }} and MongoDB ${{ matrix.mongodb-version }} on ${{ matrix.os }}
34
28
  steps:
35
- - uses: actions/checkout@v3
36
- - uses: ruby/setup-ruby@v1
29
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30
+ - uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
37
31
  with:
38
32
  ruby-version: ${{ matrix.ruby }}
39
33
  - name: Start MongoDB
40
- uses: supercharge/mongodb-github-action@1.8.0
34
+ uses: supercharge/mongodb-github-action@315db7fe45ac2880b7758f1933e6e5d59afd5e94 # v1.12.1
41
35
  with:
42
36
  mongodb-version: ${{ matrix.mongodb-version }}
43
37
  - name: unit testing
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ Release 1.6.3 - 2026/04/24
2
+
3
+ * out_mongo: Add `ordered` parameter (#210)
4
+
5
+ Release 1.6.2 - 2026/04/23
6
+
7
+ * out_mongo: prevent infinite retry on MaxBSONSize error (#206)
8
+ * out_mongo: fix NoMethodError during gracefulReload (#205)
9
+ * Add support for MongoDB 6.0, 7.0, 8.0 (#177)
10
+
1
11
  Release 1.6.1 - 2026/02/12
2
12
 
3
13
  * out_mongo: Fix RangeError by converting large integers to BSON::Decimal128
data/README.rdoc CHANGED
@@ -17,6 +17,17 @@ The gem is hosted at {Rubygems.org}[http://rubygems.org]. You can install the ge
17
17
 
18
18
  $ fluent-gem install fluent-plugin-mongo
19
19
 
20
+ === For Windows users
21
+
22
+ This plugin depends on the C extension library (such as `bson` gem) which requires a C compiler to install.
23
+
24
+ If you are using Windows, you must install the {MSYS2}[https://www.msys2.org/] development toolchain before installing this plugin:
25
+
26
+ 1. Run the following command in your command prompt:
27
+ $ ridk install
28
+ 2. Select option `3` (MSYS2 and MINGW development toolchain).
29
+ 3. Once the compiler installation is complete, run the <tt>ridk exec fluent-gem install fluent-plugin-mongo</tt> command.
30
+
20
31
  = Plugins
21
32
 
22
33
  == Output plugin
@@ -63,6 +74,10 @@ Use _mongo_ type in match.
63
74
  # eg: my_id: "507f1f77bcf86cd799439011"
64
75
  object_id_keys my_id
65
76
 
77
+ # Specify whether the operations should be executed in order (default: true).
78
+ # If false, continues to insert remaining documents even if some inserts fail.
79
+ ordered false
80
+
66
81
  # Other buffer configurations here
67
82
  </match>
68
83
 
@@ -90,7 +105,7 @@ Here is an example to use built-in placeholders:
90
105
  </buffer>
91
106
  </match>
92
107
 
93
- In more detail, please refer to the officilal document for built-in placeholders: https://docs.fluentd.org/v1.0/articles/buffer-section#placeholders
108
+ In more detail, please refer to the officilal document for built-in placeholders: https://docs.fluentd.org/configuration/buffer-section#placeholders
94
109
 
95
110
  === mongo(tag mapped mode)
96
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.1
1
+ 1.6.3
@@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.add_development_dependency "simplecov", ">= 0.5.4"
24
24
  gem.add_development_dependency "rr", ">= 1.0.0"
25
25
  gem.add_development_dependency "test-unit", ">= 3.0.0"
26
+ gem.add_development_dependency "test-unit-rr", ">= 1.0.0"
26
27
  gem.add_development_dependency "timecop", "~> 0.9.4"
27
28
  gem.add_development_dependency "webrick", ">= 1.7.0"
28
29
  end
@@ -65,6 +65,8 @@ module Fluent::Plugin
65
65
  config_param :ssl_verify, :bool, default: false
66
66
  config_param :ssl_ca_cert, :string, default: nil
67
67
 
68
+ desc "Whether the operations should be executed in order. If false, continues to insert remaining documents even if some inserts fail."
69
+ config_param :ordered, :bool, default: true
68
70
 
69
71
  config_section :buffer do
70
72
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -186,7 +188,7 @@ module Fluent::Plugin
186
188
  end
187
189
 
188
190
  def shutdown
189
- @client.close
191
+ @client&.close
190
192
  super
191
193
  end
192
194
 
@@ -355,10 +357,13 @@ module Fluent::Plugin
355
357
  replace_value_of_hash(r)
356
358
  end
357
359
 
358
- get_collection(database, collection, @collection_options).insert_many(records)
360
+ get_collection(database, collection, @collection_options).insert_many(records, ordered: @ordered)
359
361
  rescue Mongo::Error::BulkWriteError => e
360
362
  log.warn "#{records.size - e.result["n_inserted"]} documents are not inserted. Maybe these documents are invalid as a BSON."
361
363
  forget_collection(collection)
364
+ rescue Mongo::Error::MaxBSONSize => e
365
+ log.warn e
366
+ raise Fluent::UnrecoverableError, e
362
367
  rescue ArgumentError => e
363
368
  log.warn e
364
369
  end
data/test/helper.rb CHANGED
@@ -4,3 +4,5 @@ require 'mongo'
4
4
  require 'fluent/plugin/out_mongo'
5
5
  require 'fluent/plugin/out_mongo_replset'
6
6
  require 'fluent/plugin/in_mongo_tail'
7
+ require 'rr'
8
+ require 'test/unit/rr'
@@ -77,7 +77,7 @@ class MongoTailInputTest < Test::Unit::TestCase
77
77
  options = {}
78
78
  options[:database] = database_name
79
79
  @client = ::Mongo::Client.new(["localhost:#{port}"], options)
80
- @time = Time.now
80
+ @time = Time.at(Time.now.to_i)
81
81
  Timecop.freeze(@time)
82
82
  end
83
83
 
@@ -114,7 +114,7 @@ class MongoTailInputTest < Test::Unit::TestCase
114
114
  time_key time
115
115
  ])
116
116
  d.run(expect_records: 1, timeout: 5) do
117
- @client[collection_name].insert_one({message: "test", tag: "user.defined", time: Time.at(Fluent::Engine.now)})
117
+ @client[collection_name].insert_one({message: "test", tag: "user.defined", time: Time.at(Fluent::Engine.now.to_i)})
118
118
  end
119
119
  events = d.events
120
120
  assert_equal "user.defined", events[0][0]
@@ -67,6 +67,23 @@ class MongoOutputTest < ::Test::Unit::TestCase
67
67
  assert_equal({capped: true, size: 100}, d.instance.collection_options)
68
68
  assert_equal({ssl: false, write: {j: false}}, d.instance.client_options)
69
69
  assert_nil d.instance.connection_string
70
+ assert_true d.instance.ordered
71
+ end
72
+
73
+ def test_configure_with_disabled_ordered
74
+ d = create_driver(%[
75
+ @type mongo
76
+ database fluent_test
77
+ collection test_collection
78
+
79
+ ordered false
80
+ ])
81
+
82
+ assert_equal('fluent_test', d.instance.database)
83
+ assert_equal('test_collection', d.instance.collection)
84
+ assert_equal('localhost', d.instance.host)
85
+ assert_equal(port, d.instance.port)
86
+ assert_false d.instance.ordered
70
87
  end
71
88
 
72
89
  def test_configure_with_connection_string
@@ -229,8 +246,6 @@ class MongoOutputTest < ::Test::Unit::TestCase
229
246
  @type mongo
230
247
  connection_string mongodb://localhost:#{port}/#{database_name}
231
248
  collection #{collection_name}
232
- capped
233
- capped_size 100
234
249
  expire_after 120
235
250
  ])
236
251
  assert_equal("mongodb://localhost:#{port}/#{database_name}", d.instance.connection_string)
@@ -249,6 +264,24 @@ class MongoOutputTest < ::Test::Unit::TestCase
249
264
  assert_equal({"expireAfterSeconds"=>120.0}, expire_after_hash)
250
265
  end
251
266
 
267
+ def test_write_with_disabled_ordered
268
+ d = create_driver(%[
269
+ @type mongo
270
+ connection_string mongodb://localhost:#{port}/#{database_name}
271
+ collection #{collection_name}
272
+ ordered false
273
+ ])
274
+
275
+ mock_collection = Object.new
276
+ # Check the expected value is given as ordered parameter
277
+ mock(mock_collection).insert_many(anything, ordered: false)
278
+ stub(d.instance).get_collection { mock_collection }
279
+
280
+ d.run(default_tag: 'test') do
281
+ emit_documents(d)
282
+ end
283
+ end
284
+
252
285
  def test_overflow_integer_value
253
286
  d = create_driver
254
287
  d.run(default_tag: 'test') do
@@ -622,4 +655,25 @@ class MongoOutputTest < ::Test::Unit::TestCase
622
655
  assert_nil actual_documents.first['my_id']['id']
623
656
  end
624
657
  end
658
+
659
+ def test_unrecoverable_error_on_huge_document
660
+ d = create_driver(%[
661
+ @type mongo
662
+ database test
663
+ collection test_unrecoverable
664
+ <buffer>
665
+ chunk_limit_size 30m
666
+ </buffer>
667
+ ])
668
+
669
+ d.run(default_tag: 'test') do
670
+ time = event_time("2011-01-02 13:14:15 UTC")
671
+ # The document size exceeds the 16MB limit of BSON, so it should raise an UnrecoverableError.
672
+ d.feed(time, {'msg' => 'x' * (20 * 1024 * 1024)})
673
+ end
674
+
675
+ logs = d.logs.join("\n")
676
+ assert_match(/got unrecoverable error.*Fluent::UnrecoverableError/, logs)
677
+ assert_match(/MaxBSONSize/, logs)
678
+ end
625
679
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
@@ -119,6 +119,20 @@ dependencies:
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: 3.0.0
122
+ - !ruby/object:Gem::Dependency
123
+ name: test-unit-rr
124
+ requirement: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 1.0.0
129
+ type: :development
130
+ prerelease: false
131
+ version_requirements: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 1.0.0
122
136
  - !ruby/object:Gem::Dependency
123
137
  name: timecop
124
138
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +168,11 @@ executables:
154
168
  extensions: []
155
169
  extra_rdoc_files: []
156
170
  files:
171
+ - ".github/ISSUE_TEMPLATE/bug_report.yaml"
172
+ - ".github/ISSUE_TEMPLATE/config.yml"
173
+ - ".github/ISSUE_TEMPLATE/feature_request.yaml"
157
174
  - ".github/dependabot.yml"
175
+ - ".github/workflows/add-to-project.yml"
158
176
  - ".github/workflows/linux.yml"
159
177
  - ".gitignore"
160
178
  - AUTHORS
@@ -192,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
210
  - !ruby/object:Gem::Version
193
211
  version: '0'
194
212
  requirements: []
195
- rubygems_version: 4.0.3
213
+ rubygems_version: 4.0.6
196
214
  specification_version: 4
197
215
  summary: MongoDB plugin for Fluentd
198
216
  test_files: