Skip to content

Commit 1ab4800

Browse files
out_http: add config option to allow disabling logging of HTTP 2xx successes
In a busy system with lots of different tags/chunks being handled, this can get really noisy in usual operation Signed-off-by: Stewart Webb <[email protected]>
1 parent ce129af commit 1ab4800

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

plugins/out_http/http.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,18 @@ static int http_request(struct flb_out_http *ctx,
338338
}
339339
}
340340
else {
341-
if (ctx->log_response_payload &&
342-
c->resp.payload && c->resp.payload_size > 0) {
343-
flb_plg_info(ctx->ins, "%s:%i, HTTP status=%i\n%s",
344-
ctx->host, ctx->port,
345-
c->resp.status, c->resp.payload);
346-
}
347-
else {
348-
flb_plg_info(ctx->ins, "%s:%i, HTTP status=%i",
349-
ctx->host, ctx->port,
350-
c->resp.status);
341+
if (ctx->log_2xx_successes) {
342+
if (ctx->log_response_payload &&
343+
c->resp.payload && c->resp.payload_size > 0) {
344+
flb_plg_info(ctx->ins, "%s:%i, HTTP status=%i\n%s",
345+
ctx->host, ctx->port,
346+
c->resp.status, c->resp.payload);
347+
}
348+
else {
349+
flb_plg_info(ctx->ins, "%s:%i, HTTP status=%i",
350+
ctx->host, ctx->port,
351+
c->resp.status);
352+
}
351353
}
352354
}
353355
}
@@ -706,6 +708,11 @@ static struct flb_config_map config_map[] = {
706708
0, FLB_TRUE, offsetof(struct flb_out_http, log_response_payload),
707709
"Specify if the response paylod should be logged or not"
708710
},
711+
{
712+
FLB_CONFIG_MAP_BOOL, "log_2xx_successes", "true",
713+
0, FLB_TRUE, offsetof(struct flb_out_http, log_2xx_successes),
714+
"Specify if HTTP 2xx reponses should be logged or not"
715+
},
709716
{
710717
FLB_CONFIG_MAP_TIME, "http.response_timeout", "60s",
711718
0, FLB_TRUE, offsetof(struct flb_out_http, response_timeout),

plugins/out_http/http.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ struct flb_out_http {
100100
/* Log the response paylod */
101101
int log_response_payload;
102102

103+
/* Whether 200 OK etc results should be logged or not */
104+
int log_2xx_successes;
105+
103106
/* Response timeout */
104107
int response_timeout;
105108

plugins/out_http/http_conf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ struct flb_out_http *flb_http_conf_create(struct flb_output_instance *ins,
113113
}
114114
}
115115

116+
if (ctx->log_response_payload && !ctx->log_2xx_oks) {
117+
flb_plg_warn(ctx->ins, "log_response_payload is enabled but log_2xx_oks is disabled - response payloads from 2xx reponses won't be logged");
118+
}
119+
116120
/*
117121
* Check if a Proxy have been set, if so the Upstream manager will use
118122
* the Proxy end-point and then we let the HTTP client know about it, so

0 commit comments

Comments
 (0)