out_loki: get tenant_id before removing keys(#6207)
@@ -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) {
