Skip to content

Commit

Permalink
use config key "add_label" in code of plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Meyer <[email protected]>
  • Loading branch information
wndhydrnt committed Sep 24, 2023
1 parent adf20cc commit 0fdc7d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugins/filter_log_to_metrics/log_to_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ static int set_labels(struct log_to_metrics_ctx *ctx,
snprintf(label_keys[counter], MAX_LABEL_LENGTH - 1, "%s", kv->val);
counter++;
}
else if (strcasecmp(kv->key, "label") == 0) {
else if (strcasecmp(kv->key, "add_label") == 0) {
split = flb_utils_split(kv->val, ' ', 1);
if (mk_list_size(split) != 2) {
flb_plg_error(ctx->ins, "invalid label, expected name and key");
flb_plg_error(ctx->ins, "invalid add_label, expected name and key");
flb_utils_split_free(split);
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime/filter_log_to_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ void flb_test_log_to_metrics_label(void)
"metric_name", "test",
"metric_description", "Counts messages",
"kubernetes_mode", "off",
"label", "pod_name $kubernetes['pod_name']",
"add_label", "pod_name $kubernetes['pod_name']",
NULL);

out_ffd = flb_output(ctx, (char *) "lib", (void *)&cb_data);
Expand Down

0 comments on commit 0fdc7d0

Please sign in to comment.