Skip to content

Commit cf541dc

Browse files
committed
out_loki: fix removing keys defined by labels
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. Signed-off-by: jantti <[email protected]>
1 parent d77c06d commit cf541dc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

plugins/out_loki/loki.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,14 @@ static int prepare_remove_keys(struct flb_loki *ctx)
916916
return -1;
917917
}
918918
}
919-
size = mk_list_size(patterns);
919+
}
920+
921+
size = mk_list_size(patterns);
922+
if (size > 0) {
920923
flb_plg_debug(ctx->ins, "remove_mpa size: %d", size);
921-
if (size > 0) {
922-
ctx->remove_mpa = flb_mp_accessor_create(patterns);
923-
if (ctx->remove_mpa == NULL) {
924-
return -1;
925-
}
924+
ctx->remove_mpa = flb_mp_accessor_create(patterns);
925+
if (ctx->remove_mpa == NULL) {
926+
return -1;
926927
}
927928
}
928929

0 commit comments

Comments
 (0)