@@ -93,6 +93,8 @@ void flb_filter_do(struct flb_input_chunk *ic,
9393 char * ntag ;
9494 char * work_data ;
9595 size_t work_size ;
96+ size_t ingested_size ;
97+ size_t dropped_size ;
9698 void * out_buf ;
9799 size_t out_size ;
98100 struct mk_list * head ;
@@ -119,6 +121,7 @@ void flb_filter_do(struct flb_input_chunk *ic,
119121
120122 work_data = (char * ) data ;
121123 work_size = bytes ;
124+ ingested_size = bytes ;
122125
123126#ifdef FLB_HAVE_METRICS
124127 /* timestamp */
@@ -192,6 +195,10 @@ void flb_filter_do(struct flb_input_chunk *ic,
192195
193196 work_data = (char * ) out_buf ;
194197 work_size = out_size ;
198+ dropped_size = 0 ;
199+ if (ingested_size > out_size ) {
200+ dropped_size = ingested_size - out_size ;
201+ }
195202
196203 /* all records removed, no data to continue processing */
197204 if (out_size == 0 ) {
@@ -207,6 +214,8 @@ void flb_filter_do(struct flb_input_chunk *ic,
207214 /* cmetrics */
208215 cmt_counter_add (f_ins -> cmt_drop_records , ts , in_records ,
209216 1 , (char * []) {name });
217+ cmt_counter_add (f_ins -> cmt_drop_bytes , ts , dropped_size ,
218+ 1 , (char * []) {name });
210219
211220 /* [OLD] Summarize all records removed */
212221 flb_metrics_sum (FLB_METRIC_N_DROPPED ,
@@ -224,6 +233,8 @@ void flb_filter_do(struct flb_input_chunk *ic,
224233 /* cmetrics */
225234 cmt_counter_add (f_ins -> cmt_add_records , ts , diff ,
226235 1 , (char * []) {name });
236+ cmt_counter_add (f_ins -> cmt_drop_bytes , ts , dropped_size ,
237+ 1 , (char * []) {name });
227238
228239 /* [OLD] Summarize new records */
229240 flb_metrics_sum (FLB_METRIC_N_ADDED ,
@@ -235,6 +246,8 @@ void flb_filter_do(struct flb_input_chunk *ic,
235246 /* cmetrics */
236247 cmt_counter_add (f_ins -> cmt_drop_records , ts , diff ,
237248 1 , (char * []) {name });
249+ cmt_counter_add (f_ins -> cmt_drop_bytes , ts , dropped_size ,
250+ 1 , (char * []) {name });
238251
239252 /* [OLD] Summarize dropped records */
240253 flb_metrics_sum (FLB_METRIC_N_DROPPED ,
@@ -547,6 +560,14 @@ int flb_filter_init(struct flb_config *config, struct flb_filter_instance *ins)
547560 1 , (char * []) {"name" });
548561 cmt_counter_set (ins -> cmt_drop_records , ts , 0 , 1 , (char * []) {name });
549562
563+ /* Register generic filter plugin metrics */
564+ ins -> cmt_drop_bytes = cmt_counter_create (ins -> cmt ,
565+ "fluentbit" , "filter" ,
566+ "drop_bytes_total" ,
567+ "Total number of dropped bytes." ,
568+ 1 , (char * []) {"name" });
569+ cmt_counter_set (ins -> cmt_drop_bytes , ts , 0 , 1 , (char * []) {name });
570+
550571 /* OLD Metrics API */
551572#ifdef FLB_HAVE_METRICS
552573
0 commit comments