fluent-plugin-elasticsearch 1.18.0 → 1.18.1

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
  SHA256:
3
- metadata.gz: 2e6b46f67805b944adff6414e59f57c384cb02d7609440773ef3ee412bd8cb46
4
- data.tar.gz: c808857aae2e8566e88c211b3e03b69a7979fca4e09de569be972ba6f3210d5e
3
+ metadata.gz: f4e4ff948915da51a4c267d0350157b841c6b3f09862571d9777072d60d5c337
4
+ data.tar.gz: dde99b5bd72bfadad60013689d8109b5776beb6ae942d65fad1ad8777df1ecb0
5
5
  SHA512:
6
- metadata.gz: be3a97d063b6ddbe4f4fa6cb267e7453341a31a678b8385c197ad25e5eb92dad0503ab92db0a0bdda00b41522944dfd50f11666943f5af3f76044551d423a137
7
- data.tar.gz: f2ae3e1a47fc1567aa82fa79127717b53b5765b97d71cfb02564d76671ee9376ef8626c9e4bae7c8a65d68c114ecbe5436e6902d52630658dcb4ca9e08ff3396
6
+ metadata.gz: 13d604ed0ac1822333b5464efe34fd7f943b9c1151cbd2bf60c40356b028bab9164c6c66d26dd515c182d19a3f95f4b18e504d118212bf86be647b3681bd5659
7
+ data.tar.gz: d90733254d79a977a12adc64a47f01315acfe391c3841f82c055be6aef20b1c209dd6e0d86620a581efd1b8b5f90b433fb6fb640126cda122b427802fc1beec3
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.18.1
6
+ - add new option to suppress doc wrapping (porting to v0.12) (#558)
7
+
5
8
  ### 1.18.0
6
9
  - Avoid NoMethodError on unknown Elasticsearch error responses (#487)
7
10
 
data/README.md CHANGED
@@ -60,6 +60,7 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
60
60
  + [reload_after](#reload_after)
61
61
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
62
62
  + [Dynamic configuration](#dynamic-configuration)
63
+ + [suppress_doc_wrap](#suppress_doc_wrap)
63
64
  * [Contact](#contact)
64
65
  * [Contributing](#contributing)
65
66
  * [Running tests](#running-tests)
@@ -638,6 +639,12 @@ If you want configurations to depend on information in messages, you can use `el
638
639
 
639
640
  **Please note, this uses Ruby's `eval` for every message, so there are performance and security implications.**
640
641
 
642
+ ### suppress_doc_wrap
643
+
644
+ By default, record body is wrapped by 'doc'. This behavior can not handle update script requests. You can set this to suppress doc wrapping and allow record body to be untouched.
645
+
646
+ Default value is `false`.
647
+
641
648
  ## Contact
642
649
 
643
650
  If you have a question, [open an Issue](https://github.com/uken/fluent-plugin-elasticsearch/issues).
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-elasticsearch'
6
- s.version = '1.18.0'
6
+ s.version = '1.18.1'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
9
9
  s.description = %q{Elasticsearch output plugin for Fluent event collector}
@@ -90,6 +90,7 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
90
90
  config_param :emit_error_for_missing_id, :bool, :default => false
91
91
  config_param :sniffer_class_name, :string, :default => nil
92
92
  config_param :reload_after, :integer, :default => DEFAULT_RELOAD_AFTER
93
+ config_param :suppress_doc_wrap, :bool, :default => false
93
94
 
94
95
  include Fluent::ElasticsearchIndexTemplate
95
96
  include Fluent::ElasticsearchConstants
@@ -322,6 +323,9 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
322
323
 
323
324
  def update_body(record, op)
324
325
  update = remove_keys(record)
326
+ if @suppress_doc_wrap
327
+ return update
328
+ end
325
329
  body = {"doc".freeze => update}
326
330
  if op == UPSERT_OP
327
331
  if update == record
@@ -1732,4 +1732,63 @@ class ElasticsearchOutput < Test::Unit::TestCase
1732
1732
  assert_logs_include(log.out.logs, /In Fluent::ElasticsearchSimpleSniffer hosts/, 2)
1733
1733
  end
1734
1734
 
1735
+ def test_suppress_doc_wrap
1736
+ driver.configure('write_operation update
1737
+ id_key id
1738
+ remove_keys id
1739
+ suppress_doc_wrap true')
1740
+ stub_elastic_ping
1741
+ stub_elastic
1742
+ doc_body = {'field' => 'value'}
1743
+ doc_record = {'id' => 1, 'doc' => doc_body}
1744
+ script_body = {'source' => 'ctx._source.counter += params.param1',
1745
+ 'lang' => 'painless',
1746
+ 'params' => {'param1' => 1}}
1747
+ upsert_body = {'counter' => 1}
1748
+ script_record = {'id' => 2, 'script' => script_body, 'upsert' => upsert_body}
1749
+ driver.emit(doc_record, 1)
1750
+ driver.emit(script_record, 2)
1751
+ driver.run
1752
+ assert(
1753
+ index_cmds[1] == {'doc' => doc_body}
1754
+ )
1755
+ assert(
1756
+ index_cmds[3] == {
1757
+ 'script' => script_body,
1758
+ 'upsert' => upsert_body
1759
+ }
1760
+ )
1761
+ end
1762
+
1763
+ def test_suppress_doc_wrap_should_handle_record_as_is_at_upsert
1764
+ driver.configure('write_operation upsert
1765
+ id_key id
1766
+ remove_keys id
1767
+ suppress_doc_wrap true')
1768
+ stub_elastic_ping
1769
+ stub_elastic
1770
+ doc_body = {'field' => 'value'}
1771
+ doc_record = {'id' => 1, 'doc' => doc_body, 'doc_as_upsert' => true}
1772
+ script_body = {'source' => 'ctx._source.counter += params.param1',
1773
+ 'lang' => 'painless',
1774
+ 'params' => {'param1' => 1}}
1775
+ upsert_body = {'counter' => 1}
1776
+ script_record = {'id' => 2, 'script' => script_body, 'upsert' => upsert_body}
1777
+ driver.emit(doc_record, 1)
1778
+ driver.emit(script_record, 2)
1779
+ driver.run
1780
+ assert(
1781
+ index_cmds[1] == {
1782
+ 'doc' => doc_body,
1783
+ 'doc_as_upsert' => true
1784
+ }
1785
+ )
1786
+ assert(
1787
+ index_cmds[3] == {
1788
+ 'script' => script_body,
1789
+ 'upsert' => upsert_body
1790
+ }
1791
+ )
1792
+ end
1793
+
1735
1794
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-16 00:00:00.000000000 Z
12
+ date: 2019-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -176,8 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
- rubyforge_project:
180
- rubygems_version: 2.7.6
179
+ rubygems_version: 3.0.1
181
180
  signing_key:
182
181
  specification_version: 4
183
182
  summary: Elasticsearch output plugin for Fluent event collector