@@ -621,6 +621,7 @@ static int set_buckets(struct log_to_metrics_ctx *ctx,
621621static 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
649655static 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