Skip to content

Commit ec498ac

Browse files
committed
out_tcp: support 'false' value to disable json_date_key
Signed-off-by: Eduardo Silva <[email protected]>
1 parent c745241 commit ec498ac

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

plugins/out_tcp/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static void cb_tcp_flush(const void *data, size_t bytes,
8282
json = flb_pack_msgpack_to_json_format(data, bytes,
8383
ctx->out_format,
8484
ctx->json_date_format,
85-
ctx->json_date_key);
85+
ctx->date_key);
8686
if (!json) {
8787
flb_plg_error(ctx->ins, "error formatting JSON payload");
8888
flb_upstream_conn_release(u_conn);

plugins/out_tcp/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct flb_out_tcp {
3131
/* Timestamp format */
3232
int json_date_format;
3333
flb_sds_t json_date_key;
34+
flb_sds_t date_key;
3435

3536
/* Upstream connection to the backend server */
3637
struct flb_upstream *u;

plugins/out_tcp/tcp_conf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ struct flb_out_tcp *flb_tcp_conf_create(struct flb_output_instance *ins,
9393
}
9494
}
9595

96+
/* Date key */
97+
ctx->date_key = ctx->json_date_key;
98+
tmp = flb_output_get_property("json_date_key", ins);
99+
if (tmp) {
100+
/* Just check if we have to disable it */
101+
if (flb_utils_bool(tmp) == FLB_FALSE) {
102+
ctx->date_key = NULL;
103+
}
104+
}
105+
96106
/* Date format for JSON output */
97107
ctx->json_date_format = FLB_PACK_JSON_DATE_DOUBLE;
98108
tmp = flb_output_get_property("json_date_format", ins);

0 commit comments

Comments
 (0)