Skip to content

Commit

Permalink
filter_log_to_metrics: if add_label is not record accessor, use the s…
Browse files Browse the repository at this point in the history
…tring

Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
  • Loading branch information
edsiper committed Aug 1, 2024
1 parent 93daf38 commit 4e0e77b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plugins/filter_log_to_metrics/log_to_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values,
label_iterator_start = NUMBER_OF_KUBERNETES_LABELS;
}

for (i = label_iterator_start; i < label_counter; i++){
for (i = label_iterator_start; i < label_counter; i++) {
if (*label_accessors[i] != '$'){
snprintf(label_values[i], MAX_LABEL_LENGTH - 1, "%s", label_accessors[i]);
continue;
}

ra = flb_ra_create(label_accessors[i], FLB_TRUE);
if (!ra) {
flb_warn("invalid record accessor key, aborting");
Expand All @@ -415,9 +420,10 @@ static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values,

rval = flb_ra_get_value_object(ra, map);
if (!rval) {
/* Set value to empty string, so the value will be dropped in Cmetrics*/
label_values[i][0] = '\0';
} else if (rval->type == FLB_RA_STRING) {
/* Set value to empty string, so the value will be dropped in Cmetrics*/
label_values[i][0] = '\0';
}
else if (rval->type == FLB_RA_STRING) {
snprintf(label_values[i], MAX_LABEL_LENGTH - 1, "%s",
rval->val.string);
}
Expand Down

0 comments on commit 4e0e77b

Please sign in to comment.