Skip to content

Commit 7d81074

Browse files
authored
Log bulk request response body on error, not just when debug logging is set (#1096)
Prior to this commit, an error response to a bulk request would only log the response body when debug logging is enabled. This removes an important piece of information when tracking down issues, which is particularly important in this case, as an error response to a bulk request may result in requests being retried indefinitely, causing pipeline stalls. This commit adds the response body to the `log_hash` regardless of the log level,so 429 responses will remain unchanged, and will only log when debug is enabled, but other error responses will include the response body to add this additional context to help track down issues Closes: #999
1 parent 7c24cfa commit 7d81074

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 11.12.1
2+
- Log bulk request response body on error, not just when debug logging is enabled [#1096](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1096)
3+
14
## 11.12.0
25
- Add legacy template API support for Elasticsearch 8 [#1092](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1092)
36

lib/logstash/plugin_mixins/elasticsearch/common.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ def safe_bulk(actions)
335335
retry unless @stopping.true?
336336
rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError => e
337337
@bulk_request_metrics.increment(:failures)
338-
log_hash = {:code => e.response_code, :url => e.url.sanitized.to_s, :content_length => e.request_body.bytesize}
339-
log_hash[:body] = e.response_body if @logger.debug? # Generally this is too verbose
338+
log_hash = {:code => e.response_code, :url => e.url.sanitized.to_s,
339+
:content_length => e.request_body.bytesize, :body => e.response_body}
340340
message = "Encountered a retryable error (will retry with exponential backoff)"
341341

342342
# We treat 429s as a special case because these really aren't errors, but

logstash-output-elasticsearch.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-elasticsearch'
3-
s.version = '11.12.0'
3+
s.version = '11.12.1'
44
s.licenses = ['apache-2.0']
55
s.summary = "Stores logs in Elasticsearch"
66
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"

0 commit comments

Comments
 (0)