From fc45581725799178214ebc04d051aa3546879c28 Mon Sep 17 00:00:00 2001 From: Israel Zeromski Date: Thu, 23 May 2024 12:03:59 -0300 Subject: [PATCH] out_http: don't retry non retryable 4xx status codes Fix a problem that http output plugin retries all requests that respond with an 4xx status code excepting 429 status code Signed-off-by: Israel Zeromski --- plugins/out_http/http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/out_http/http.c b/plugins/out_http/http.c index 17840975309..84879e09c38 100644 --- a/plugins/out_http/http.c +++ b/plugins/out_http/http.c @@ -276,7 +276,15 @@ static int http_post(struct flb_out_http *ctx, flb_plg_error(ctx->ins, "%s:%i, HTTP status=%i", ctx->host, ctx->port, c->resp.status); } - out_ret = FLB_RETRY; + if (c->resp.status >= 400 && c->resp.status < 500 && c->resp.status != 429) { + flb_plg_warn(ctx->ins, "could not flush records to %s:%i (http_do=%i), " + "chunk will not be retried", + ctx->host, ctx->port, ret); + out_ret = FLB_ERROR; + } + else { + out_ret = FLB_RETRY; + } } else { if (ctx->log_response_payload &&