Skip to content

Commit

Permalink
out_loki: get tenant_id before removing keys(fluent#6207)
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
  • Loading branch information
nokute78 authored and edsiper committed Oct 21, 2022
1 parent 101f9da commit c4e36d7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugins/out_loki/loki.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit c4e36d7

Please sign in to comment.