Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/logstash/plugin_mixins/elasticsearch/common.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "logstash/outputs/elasticsearch/template_manager"
require "logstash/json"

module LogStash; module PluginMixins; module ElasticSearch
module Common
Expand Down Expand Up @@ -237,8 +238,8 @@ def handle_dlq_response(message, action, status, response)

if @dlq_writer
# TODO: Change this to send a map with { :status => status, :action => action } in the future
detailed_message = "#{message} status: #{status}, action: #{action_params}, response: #{response}"
@dlq_writer.write(event, "#{detailed_message}")
detailed_message = "#{message} status: #{status}, action: #{LogStash::Json.dump(action_params)}, response: #{LogStash::Json.dump(response)}"
@dlq_writer.write(event, detailed_message)
else
log_level = dig_value(response, 'index', 'error', 'type') == 'invalid_index_name_exception' ? :error : :warn

Expand Down
4 changes: 3 additions & 1 deletion spec/unit/outputs/elasticsearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,9 @@
expect( event ).to be_a LogStash::Event
expect( event ).to be events.first
expect( reason ).to start_with "Could not index event to Elasticsearch. status: #{error_code}, action: [\"index\""
expect( reason ).to match /_id=>"bar".*"foo"=>"bar".*response:.*"reason"=>"TEST"/
expect( reason ).to include '"_id":"bar"'
expect( reason ).to include '"foo":"bar"'
expect( reason ).to include '"reason":"TEST"'

method.call(*args) # won't hurt to call LogStash::Util::DummyDeadLetterQueueWriter
end.once
Expand Down