Skip to content

Commit

Permalink
filter: Add drop_bytes metrics for old metrics API
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Sep 25, 2024
1 parent 535f748 commit 2604ce4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/fluent-bit/flb_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
#include <cmetrics/cmt_filter.h>

/* 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 */
Expand Down
7 changes: 7 additions & 0 deletions src/flb_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand All @@ -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

Expand Down Expand Up @@ -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

/*
Expand Down

0 comments on commit 2604ce4

Please sign in to comment.