From 6a02f8707c87a2cc39cbf3a908a135db4fe07cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Wed, 5 Jul 2023 16:27:00 +0100 Subject: [PATCH 1/2] skip processing of bulk response on a 200 OK --- lib/logstash/outputs/elasticsearch/http_client.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/logstash/outputs/elasticsearch/http_client.rb b/lib/logstash/outputs/elasticsearch/http_client.rb index 082751ce..0bb21a72 100644 --- a/lib/logstash/outputs/elasticsearch/http_client.rb +++ b/lib/logstash/outputs/elasticsearch/http_client.rb @@ -179,7 +179,15 @@ def bulk_send(body_stream, batch_actions) case response.code when 200 # OK - LogStash::Json.load(response.body) + body = response.body + if body[0..40].match?(/"errors":false/) && ENV["SHORT_CIRCUIT"] == "1" + # fake a successful bulk response + # {"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]} + {"errors": false, "items": []} + else + LogStash::Json.load(body) + end + when 413 # Payload Too Large logger.warn("Bulk request rejected: `413 Payload Too Large`", :action_count => batch_actions.size, :content_length => body_stream.size) emulate_batch_error_response(batch_actions, response.code, 'payload_too_large') From 3bd51f1fa39b2d0e2e71ef5add53bcc462cb8381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 7 Jul 2023 09:29:28 +0100 Subject: [PATCH 2/2] Update lib/logstash/outputs/elasticsearch/http_client.rb --- lib/logstash/outputs/elasticsearch/http_client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logstash/outputs/elasticsearch/http_client.rb b/lib/logstash/outputs/elasticsearch/http_client.rb index 0bb21a72..9825e807 100644 --- a/lib/logstash/outputs/elasticsearch/http_client.rb +++ b/lib/logstash/outputs/elasticsearch/http_client.rb @@ -180,7 +180,7 @@ def bulk_send(body_stream, batch_actions) case response.code when 200 # OK body = response.body - if body[0..40].match?(/"errors":false/) && ENV["SHORT_CIRCUIT"] == "1" + if body[0..40].match?(/"errors":false/) # fake a successful bulk response # {"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]} {"errors": false, "items": []}