Skip to content

Commit

Permalink
filter: add total processing volume metrics
Browse files Browse the repository at this point in the history
Instead of just having metrics for number of records added/dropped, we
now also have metrics for the total number of records and bytes
processed by each filter.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: root <root@sumit-acs.novalocal>
  • Loading branch information
seveas authored and root committed Feb 8, 2023
1 parent a533df7 commit 2319923
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/fluent-bit/flb_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ struct flb_filter_instance {
* --------
*/
struct cmt *cmt; /* parent context */
struct cmt_counter *cmt_records; /* m: filter_records_total */
struct cmt_counter *cmt_bytes; /* m: filter_bytes_total */
struct cmt_counter *cmt_add_records; /* m: filter_add_records_total */
struct cmt_counter *cmt_drop_records; /* m: filter_drop_records_total */

Expand Down
26 changes: 26 additions & 0 deletions src/flb_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ void flb_filter_do(struct flb_input_chunk *ic,

#ifdef FLB_HAVE_METRICS
name = (char *) flb_filter_name(f_ins);

cmt_counter_add(f_ins->cmt_records, ts, in_records,
1, (char *[]) {name});
cmt_counter_add(f_ins->cmt_bytes, ts, content_size,
1, (char *[]) {name});

flb_metrics_sum(FLB_METRIC_N_RECORDS, in_records, f_ins->metrics);
flb_metrics_sum(FLB_METRIC_N_BYTES, content_size, f_ins->metrics);
#endif

/* Override buffer just if it was modified */
Expand Down Expand Up @@ -442,6 +450,22 @@ int flb_filter_init_all(struct flb_config *config)
return -1;
}

/* Register generic filter plugin metrics */
ins->cmt_records = cmt_counter_create(ins->cmt,
"fluentbit", "filter",
"records_total",
"Total number of new records processed.",
1, (char *[]) {"name"});
cmt_counter_set(ins->cmt_records, ts, 0, 1, (char *[]) {name});

/* Register generic filter plugin metrics */
ins->cmt_bytes = cmt_counter_create(ins->cmt,
"fluentbit", "filter",
"bytes_total",
"Total number of new bytes processed.",
1, (char *[]) {"name"});
cmt_counter_set(ins->cmt_bytes, ts, 0, 1, (char *[]) {name});

/* Register generic filter plugin metrics */
ins->cmt_add_records = cmt_counter_create(ins->cmt,
"fluentbit", "filter",
Expand Down Expand Up @@ -474,6 +498,8 @@ int flb_filter_init_all(struct flb_config *config)
/* Register filter metrics */
flb_metrics_add(FLB_METRIC_N_DROPPED, "drop_records", ins->metrics);
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);
#endif

/*
Expand Down

0 comments on commit 2319923

Please sign in to comment.