diff --git a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/BulkRetryStrategy.java b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/BulkRetryStrategy.java index b075fe7730..451d153bfa 100644 --- a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/BulkRetryStrategy.java +++ b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/BulkRetryStrategy.java @@ -238,6 +238,13 @@ private BulkOperationRequestResponse handleRetriesAndFailures(final Accumulating if (doRetry) { if (retryCount % 5 == 0) { LOG.warn("Bulk Operation Failed. Number of retries {}. Retrying... ", retryCount, e); + if (e == null) { + for (final BulkResponseItem bulkItemResponse : bulkResponse.items()) { + if (Objects.nonNull(bulkItemResponse.error())) { + LOG.warn("operation = {}, error = {}", bulkItemResponse.operationType(), bulkItemResponse.error()); + } + } + } } bulkRequestNumberOfRetries.increment(); return new BulkOperationRequestResponse(bulkRequestForRetry, bulkResponse); @@ -248,7 +255,13 @@ private BulkOperationRequestResponse handleRetriesAndFailures(final Accumulating } private void handleFailures(final AccumulatingBulkRequest bulkRequest, final BulkResponse bulkResponse, final Throwable failure) { - if (Objects.isNull(failure)) { + LOG.warn("Bulk Operation Failed.", failure); + if (failure == null) { + for (final BulkResponseItem bulkItemResponse : bulkResponse.items()) { + if (Objects.nonNull(bulkItemResponse.error())) { + LOG.warn("operation = {}, error = {}", bulkItemResponse.operationType(), bulkItemResponse.error()); + } + } handleFailures(bulkRequest, bulkResponse.items()); } else { handleFailures(bulkRequest, failure);