@@ -369,18 +369,24 @@ static int cb_ml_init(struct flb_filter_instance *ins,
369
369
"fluentbit" , "filter" , "emit_records_total" ,
370
370
"Total number of emitted records" ,
371
371
1 , (char * []) {"name" });
372
+
373
+ /* OLD api */
374
+ flb_metrics_add (FLB_MULTILINE_METRIC_EMITTED ,
375
+ "emit_records" , ctx -> ins -> metrics );
376
+ #endif
377
+ }
378
+ /* Register a metric to count the number of emitted records */
379
+ /* Truncated metrics always should be existing. */
380
+ #ifdef FLB_HAVE_METRICS
372
381
ctx -> cmt_truncated = cmt_counter_create (ins -> cmt ,
373
382
"fluentbit" , "filter" , "emit_truncated_total" ,
374
383
"Total number of truncated occurence of multiline" ,
375
384
1 , (char * []) {"name" });
376
385
377
386
/* OLD api */
378
- flb_metrics_add (FLB_MULTILINE_METRIC_EMITTED ,
379
- "emit_records" , ctx -> ins -> metrics );
380
387
flb_metrics_add (FLB_MULTILINE_METRIC_TRUNCATED ,
381
388
"emit_truncated" , ctx -> ins -> metrics );
382
389
#endif
383
- }
384
390
385
391
mk_list_init (& ctx -> ml_streams );
386
392
mk_list_init (& ctx -> split_message_packers );
@@ -846,16 +852,6 @@ static int cb_ml_filter(const void *data, size_t bytes,
846
852
flb_plg_debug (ctx -> ins ,
847
853
"could not append object from tag: %s" , tag );
848
854
}
849
- else if (ret == FLB_MULTILINE_OK ) {
850
- #ifdef FLB_HAVE_METRICS
851
- name = (char * ) flb_filter_name (ctx -> ins );
852
- ts = cfl_time_now ();
853
- cmt_counter_inc (ctx -> cmt_emitted , ts , 1 , (char * []) {name });
854
-
855
- /* old api */
856
- flb_metrics_sum (FLB_MULTILINE_METRIC_EMITTED , 1 , ctx -> ins -> metrics );
857
- #endif
858
- }
859
855
}
860
856
861
857
flb_log_event_decoder_destroy (& decoder );
0 commit comments