Skip to content

Commit 5a0049f

Browse files
committed
filter_log_to_metrics: retry timer metric append
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent 0544ad7 commit 5a0049f

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

plugins/filter_log_to_metrics/log_to_metrics.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ static int set_buckets(struct log_to_metrics_ctx *ctx,
621621
static void cb_send_metric_chunk(struct flb_config *config, void *data)
622622
{
623623
int ret;
624+
int appended = FLB_FALSE;
624625
struct log_to_metrics_ctx *ctx = data;
625626

626627
/* Check that metric context is not empty */
@@ -630,10 +631,13 @@ static void cb_send_metric_chunk(struct flb_config *config, void *data)
630631

631632
if (ctx->new_data) {
632633
ret = flb_input_metrics_append(ctx->input_ins, ctx->tag,
633-
strlen(ctx->tag), ctx->cmt);
634+
strlen(ctx->tag), ctx->cmt);
634635
if (ret != 0) {
635636
flb_plg_error(ctx->ins, "could not append metrics");
636637
}
638+
else {
639+
appended = FLB_TRUE;
640+
}
637641
}
638642

639643
/* Check if we are shutting down. If so, stop our timer */
@@ -643,7 +647,9 @@ static void cb_send_metric_chunk(struct flb_config *config, void *data)
643647
flb_sched_timer_cb_disable(ctx->timer);
644648
}
645649
}
646-
ctx->new_data = FLB_FALSE;
650+
if (appended) {
651+
ctx->new_data = FLB_FALSE;
652+
}
647653
}
648654

649655
static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins,
@@ -1124,7 +1130,9 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes,
11241130
}
11251131
}
11261132
else {
1127-
ctx->new_data = FLB_TRUE;
1133+
if (ret == 0) {
1134+
ctx->new_data = FLB_TRUE;
1135+
}
11281136
}
11291137
}
11301138
else if (ret == GREP_RET_EXCLUDE) {

0 commit comments

Comments
 (0)