File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -902,13 +902,25 @@ static void cb_opensearch_flush(struct flb_event_chunk *event_chunk,
902902 /* we got an error */
903903 if (ctx -> trace_error ) {
904904 /*
905- * If trace_error is set, trace the actual input/output to
906- * OpenSearch that caused the problem.
905+ * If trace_error is set, trace the actual
906+ * response from Elasticsearch explaining the problem.
907+ * Trace_Output can be used to see the request.
907908 */
908- flb_plg_debug (ctx -> ins , "error caused by: Input\n%s\n" ,
909- pack );
910- flb_plg_error (ctx -> ins , "error: Output\n%s" ,
911- c -> resp .payload );
909+ if (pack_size < 4000 ) {
910+ flb_plg_debug (ctx -> ins , "error caused by: Input\n%.*s\n" ,
911+ (int ) pack_size , pack );
912+ }
913+ if (c -> resp .payload_size < 4000 ) {
914+ flb_plg_error (ctx -> ins , "error: Output\n%s" ,
915+ c -> resp .payload );
916+ } else {
917+ /*
918+ * We must use fwrite since the flb_log functions
919+ * will truncate data at 4KB
920+ */
921+ fwrite (c -> resp .payload , 1 , c -> resp .payload_size , stderr );
922+ fflush (stderr );
923+ }
912924 }
913925 goto retry ;
914926 }
You can’t perform that action at this time.
0 commit comments