From c4e36d7b670cbd957d767f05098984b208663d78 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Thu, 20 Oct 2022 20:40:23 +0900 Subject: [PATCH] out_loki: get tenant_id before removing keys(#6207) Signed-off-by: Takahiro Yamashita --- plugins/out_loki/loki.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/out_loki/loki.c b/plugins/out_loki/loki.c index 6e1ad1bec9d..ae86b0f148c 100644 --- a/plugins/out_loki/loki.c +++ b/plugins/out_loki/loki.c @@ -1120,6 +1120,14 @@ static int pack_record(struct flb_loki *ctx, msgpack_unpacked mp_buffer; size_t off = 0; + /* + * Get tenant id from record before removing keys. + * https://github.com/fluent/fluent-bit/issues/6207 + */ + if (ctx->ra_tenant_id_key && rec->type == MSGPACK_OBJECT_MAP) { + get_tenant_id_from_record(ctx, rec); + } + /* Remove keys in remove_keys */ msgpack_unpacked_init(&mp_buffer); if (ctx->remove_mpa) { @@ -1136,11 +1144,6 @@ static int pack_record(struct flb_loki *ctx, } } - // Get tenant id from record. - if (ctx->ra_tenant_id_key && rec->type == MSGPACK_OBJECT_MAP) { - get_tenant_id_from_record(ctx, rec); - } - /* Drop single key */ if (ctx->drop_single_key == FLB_TRUE && rec->type == MSGPACK_OBJECT_MAP && rec->via.map.size == 1) { if (ctx->out_line_format == FLB_LOKI_FMT_JSON) {