Skip to content

Commit 217c559

Browse files
PettitWesleyedsiper
authored andcommitted
out_es: fix trace_error truncating the response
Signed-off-by: Wesley Pettit <[email protected]>
1 parent e3d4338 commit 217c559

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

plugins/out_es/es.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,12 +916,24 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
916916
if (ctx->trace_error) {
917917
/*
918918
* If trace_error is set, trace the actual
919-
* input/output to Elasticsearch that caused the problem.
919+
* response from Elasticsearch explaining the problem.
920+
* Trace_Output can be used to see the request.
920921
*/
921-
flb_plg_debug(ctx->ins, "error caused by: Input\n%s\n",
922-
pack);
923-
flb_plg_error(ctx->ins, "error: Output\n%s",
924-
c->resp.payload);
922+
if (pack_size < 4000) {
923+
flb_plg_debug(ctx->ins, "error caused by: Input\n%.*s\n",
924+
(int) pack_size, pack);
925+
}
926+
if (c->resp.payload_size < 4000) {
927+
flb_plg_error(ctx->ins, "error: Output\n%s",
928+
c->resp.payload);
929+
} else {
930+
/*
931+
* We must use fwrite since the flb_log functions
932+
* will truncate data at 4KB
933+
*/
934+
fwrite(c->resp.payload, 1, c->resp.payload_size, stderr);
935+
fflush(stderr);
936+
}
925937
}
926938
goto retry;
927939
}

0 commit comments

Comments
 (0)