Skip to content

Commit

Permalink
out_loki: fix removing keys defined by labels
Browse files Browse the repository at this point in the history
When key is defined as a Loki label with labels, label_keys or
label_map_path, the code is trying to remove them. However, if
remove_keys is not defined, it never gets to the part that actually
removes them. This looks like an obvious bug to me.

I moved the debug message to inside the if (size > 0) statement, because
earlier it would only print it if it was actually trying to remove
something. So without moving it it would spam it every time. And absence
of the message would then indicate size == 0. Not sure if this is the
best, though.
  • Loading branch information
ajantti committed Dec 25, 2024
1 parent d77c06d commit c53b61c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugins/out_loki/loki.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,14 @@ static int prepare_remove_keys(struct flb_loki *ctx)
return -1;
}
}
size = mk_list_size(patterns);
}

size = mk_list_size(patterns);
if (size > 0) {
flb_plg_debug(ctx->ins, "remove_mpa size: %d", size);
if (size > 0) {
ctx->remove_mpa = flb_mp_accessor_create(patterns);
if (ctx->remove_mpa == NULL) {
return -1;
}
ctx->remove_mpa = flb_mp_accessor_create(patterns);
if (ctx->remove_mpa == NULL) {
return -1;
}
}

Expand Down

0 comments on commit c53b61c

Please sign in to comment.