logstash-output-elasticsearch 9.1.3-java → 9.1.4-java

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: c039da495adec68b5bb57018b408430dede45c5389744d0d8b043d6210a60d08
4
- data.tar.gz: e2a28d5dee5519a151fd501d61f41b1bf182dcd2f262a0b2588b6be7272c2067
3
+ metadata.gz: a8917f99f05252cd3a9386839e0dbdbcc5196660620a60f15b3505979f76dcde
4
+ data.tar.gz: f0eff97eb0951baa55a73db99131784ee9ddfd6498eab5b6d0bbf616582e728c
5
5
  SHA512:
6
- metadata.gz: 4fa67d4e34cbf2d0c7de02cece71c2ea1e938a820a839878d9d07535590da657b71069312d843ef37e6e444f24149d165f61189abff7f0d4d59e1e0273d06cde
7
- data.tar.gz: 908fed926ba7ccdecbd77f6e1493a811214824756e396f287ca9e82b5dd280c60b79c51299c4963bf0e1168561404a3d567a63f5f930915658a062e914289cc1
6
+ metadata.gz: 1832b2292c90c7c63ac4390a615abbd4215351f5949ec33d1e9a51e450af9066a09294cdb89b9bb24a9eed77d9546860eb929c80d6c515acb507b7c6bbab4397
7
+ data.tar.gz: 6bee0365e4003c390e098901ae6ec0f62dec19123b7cdef184bed92eecb9c1d54cf5bfc0130a202f0f8cae72c5ae1fbb3eb89cfdd7731ebba0da7afc816eff50
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 9.1.4
2
+ - Log an error -- not a warning -- when ES raises an invalid\_index\_name\_exception.
3
+
1
4
  ## 9.1.3
2
5
  - Improve plugin behavior when Elasticsearch is down on startup #758
3
6
 
@@ -213,14 +213,7 @@ module LogStash; module Outputs; class ElasticSearch;
213
213
  @logger.warn "Failed action.", status: status, action: action, response: response if !failure_type_logging_whitelist.include?(failure["type"])
214
214
  next
215
215
  elsif DOC_DLQ_CODES.include?(status)
216
- action_event = action[2]
217
- # To support bwc, we check if DLQ exists. otherwise we log and drop event (previous behavior)
218
- if @dlq_writer
219
- # TODO: Change this to send a map with { :status => status, :action => action } in the future
220
- @dlq_writer.write(action_event, "Could not index event to Elasticsearch. status: #{status}, action: #{action}, response: #{response}")
221
- else
222
- @logger.warn "Could not index event to Elasticsearch.", status: status, action: action, response: response
223
- end
216
+ handle_dlq_status("Could not index event to Elasticsearch.", action, status, response)
224
217
  @document_level_metrics.increment(:non_retryable_failures)
225
218
  next
226
219
  else
@@ -234,6 +227,22 @@ module LogStash; module Outputs; class ElasticSearch;
234
227
  actions_to_retry
235
228
  end
236
229
 
230
+ def handle_dlq_status(message, action, status, response)
231
+ # To support bwc, we check if DLQ exists. otherwise we log and drop event (previous behavior)
232
+ if @dlq_writer
233
+ # TODO: Change this to send a map with { :status => status, :action => action } in the future
234
+ @dlq_writer.write(action[2], "#{message} status: #{status}, action: #{action}, response: #{response}")
235
+ else
236
+ error_type = response.fetch('index', {}).fetch('error', {})['type']
237
+ if 'invalid_index_name_exception' == error_type
238
+ level = :error
239
+ else
240
+ level = :warn
241
+ end
242
+ @logger.send level, message, status: status, action: action, response: response
243
+ end
244
+ end
245
+
237
246
  # Determine the correct value for the 'type' field for the given event
238
247
  DEFAULT_EVENT_TYPE_ES6="doc".freeze
239
248
  DEFAULT_EVENT_TYPE_ES7="_doc".freeze
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '9.1.3'
3
+ s.version = '9.1.4'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -2,6 +2,12 @@ require "logstash/devutils/rspec/spec_helper"
2
2
  require 'manticore'
3
3
  require 'elasticsearch'
4
4
 
5
+ # by default exclude secure_integration tests unless requested
6
+ # normal integration specs are already excluded by devutils' spec helper
7
+ RSpec.configure do |config|
8
+ config.filter_run_excluding config.exclusion_filter.add(:secure_integration => true)
9
+ end
10
+
5
11
  module ESHelper
6
12
  def get_host_port
7
13
  "127.0.0.1:9200"
@@ -17,6 +23,10 @@ module ESHelper
17
23
 
18
24
  def self.es_version_satisfies?(*requirement)
19
25
  es_version = RSpec.configuration.filter[:es_version] || ENV['ES_VERSION']
26
+ if es_version.nil?
27
+ puts "Info: ES_VERSION environment or 'es_version' tag wasn't set. Returning false to all `es_version_satisfies?` call."
28
+ return false
29
+ end
20
30
  es_release_version = Gem::Version.new(es_version).release
21
31
  Gem::Requirement.new(requirement).satisfied_by?(es_release_version)
22
32
  end
@@ -129,7 +129,7 @@ describe "indexing" do
129
129
  it_behaves_like("an indexer")
130
130
  end
131
131
 
132
- describe "a secured indexer", :elasticsearch_secure => true do
132
+ describe "a secured indexer", :secure_integration => true do
133
133
  let(:user) { "simpleuser" }
134
134
  let(:password) { "abc123" }
135
135
  let(:cacert) { "spec/fixtures/test_certs/test.crt" }
@@ -17,7 +17,7 @@ describe LogStash::Outputs::ElasticSearch do
17
17
  allow(subject.client.pool).to receive(:start_resurrectionist)
18
18
  allow(subject.client.pool).to receive(:start_sniffer)
19
19
  allow(subject.client.pool).to receive(:healthcheck!)
20
- allow(subject.client).to receive(:maximum_seen_major_version).and_return(maximum_seen_major_version)
20
+ allow(subject.client).to receive(:maximum_seen_major_version).at_least(:once).and_return(maximum_seen_major_version)
21
21
  subject.client.pool.adapter.manticore.respond_with(:body => "{}")
22
22
  end
23
23
  end
@@ -358,6 +358,7 @@ describe LogStash::Outputs::ElasticSearch do
358
358
  let(:options) { super.merge("action" => "index") }
359
359
 
360
360
  it "should not set the retry_on_conflict parameter when creating an event_action_tuple" do
361
+ allow(subject.client).to receive(:maximum_seen_major_version).and_return(maximum_seen_major_version)
361
362
  action, params, event_data = subject.event_action_tuple(event)
362
363
  expect(params).not_to include({:_retry_on_conflict => num_retries})
363
364
  end
@@ -498,4 +499,60 @@ describe LogStash::Outputs::ElasticSearch do
498
499
  end
499
500
  end
500
501
  end
502
+
503
+ context 'handling elasticsearch document-level status meant for the DLQ' do
504
+ let(:options) { { "manage_template" => false } }
505
+ let(:logger) { subject.instance_variable_get(:@logger) }
506
+
507
+ context 'when @dlq_writer is nil' do
508
+ before { subject.instance_variable_set '@dlq_writer', nil }
509
+
510
+ context 'resorting to previous behaviour of logging the error' do
511
+ context 'getting an invalid_index_name_exception' do
512
+ it 'should log at ERROR level' do
513
+ expect(logger).to receive(:error).with(/Could not index/, hash_including(:status, :action, :response))
514
+ mock_response = { 'index' => { 'error' => { 'type' => 'invalid_index_name_exception' } } }
515
+ subject.handle_dlq_status("Could not index event to Elasticsearch.",
516
+ [:action, :params, :event], :some_status, mock_response)
517
+ end
518
+ end
519
+
520
+ context 'when getting any other exception' do
521
+ it 'should log at WARN level' do
522
+ expect(logger).to receive(:warn).with(/Could not index/, hash_including(:status, :action, :response))
523
+ mock_response = { 'index' => { 'error' => { 'type' => 'illegal_argument_exception' } } }
524
+ subject.handle_dlq_status("Could not index event to Elasticsearch.",
525
+ [:action, :params, :event], :some_status, mock_response)
526
+ end
527
+ end
528
+
529
+ context 'when the response does not include [error]' do
530
+ it 'should not fail, but just log a warning' do
531
+ expect(logger).to receive(:warn).with(/Could not index/, hash_including(:status, :action, :response))
532
+ mock_response = { 'index' => {} }
533
+ expect do
534
+ subject.handle_dlq_status("Could not index event to Elasticsearch.",
535
+ [:action, :params, :event], :some_status, mock_response)
536
+ end.to_not raise_error
537
+ end
538
+ end
539
+ end
540
+ end
541
+
542
+ # DLQ writer always nil, no matter what I try here. So mocking it all the way
543
+ context 'when DLQ is enabled' do
544
+ let(:dlq_writer) { double('DLQ writer') }
545
+ before { subject.instance_variable_set('@dlq_writer', dlq_writer) }
546
+
547
+ # Note: This is not quite the desired behaviour.
548
+ # We should still log when sending to the DLQ.
549
+ # This shall be solved by another issue, however: logstash-output-elasticsearch#772
550
+ it 'should send the event to the DLQ instead, and not log' do
551
+ expect(dlq_writer).to receive(:write).with(:event, /Could not index/)
552
+ mock_response = { 'index' => { 'error' => { 'type' => 'illegal_argument_exception' } } }
553
+ subject.handle_dlq_status("Could not index event to Elasticsearch.",
554
+ [:action, :params, :event], :some_status, mock_response)
555
+ end
556
+ end
557
+ end
501
558
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.3
4
+ version: 9.1.4
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-15 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement