From 2604ce4455605608e9ea18d5fc058829a7982b98 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 25 Sep 2024 13:18:43 +0900 Subject: [PATCH] filter: Add drop_bytes metrics for old metrics API Signed-off-by: Hiroshi Hatake --- include/fluent-bit/flb_metrics.h | 9 +++++---- src/flb_filter.c | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/fluent-bit/flb_metrics.h b/include/fluent-bit/flb_metrics.h index fa7541ac047..b57a1d06bed 100644 --- a/include/fluent-bit/flb_metrics.h +++ b/include/fluent-bit/flb_metrics.h @@ -43,10 +43,11 @@ #include /* Metrics IDs for general purpose (used by core and Plugins */ -#define FLB_METRIC_N_RECORDS 0 -#define FLB_METRIC_N_BYTES 1 -#define FLB_METRIC_N_DROPPED 2 -#define FLB_METRIC_N_ADDED 3 +#define FLB_METRIC_N_RECORDS 0 +#define FLB_METRIC_N_BYTES 1 +#define FLB_METRIC_N_DROPPED 2 +#define FLB_METRIC_N_ADDED 3 +#define FLB_METRIC_N_DROPPED_BYTES 4 /* Genaral output plugin metrics */ #define FLB_METRIC_OUT_OK_RECORDS 10 /* proc_records */ diff --git a/src/flb_filter.c b/src/flb_filter.c index 01bfad2cfaf..b4829a6d7d9 100644 --- a/src/flb_filter.c +++ b/src/flb_filter.c @@ -220,6 +220,8 @@ void flb_filter_do(struct flb_input_chunk *ic, /* [OLD] Summarize all records removed */ flb_metrics_sum(FLB_METRIC_N_DROPPED, in_records, f_ins->metrics); + flb_metrics_sum(FLB_METRIC_N_DROPPED_BYTES, + dropped_size, f_ins->metrics); #endif break; } @@ -239,6 +241,8 @@ void flb_filter_do(struct flb_input_chunk *ic, /* [OLD] Summarize new records */ flb_metrics_sum(FLB_METRIC_N_ADDED, diff, f_ins->metrics); + flb_metrics_sum(FLB_METRIC_N_DROPPED_BYTES, + dropped_size, f_ins->metrics); } else if (out_records < in_records) { diff = (in_records - out_records); @@ -252,6 +256,8 @@ void flb_filter_do(struct flb_input_chunk *ic, /* [OLD] Summarize dropped records */ flb_metrics_sum(FLB_METRIC_N_DROPPED, diff, f_ins->metrics); + flb_metrics_sum(FLB_METRIC_N_DROPPED_BYTES, + dropped_size, f_ins->metrics); } #endif @@ -584,6 +590,7 @@ int flb_filter_init(struct flb_config *config, struct flb_filter_instance *ins) flb_metrics_add(FLB_METRIC_N_ADDED, "add_records", ins->metrics); flb_metrics_add(FLB_METRIC_N_RECORDS, "records", ins->metrics); flb_metrics_add(FLB_METRIC_N_BYTES, "bytes", ins->metrics); + flb_metrics_add(FLB_METRIC_N_DROPPED_BYTES, "drop_bytes", ins->metrics); #endif /*