Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input_chunk: fix input plugin metrics not counting records re-emitted by filters downstream #9487

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/flb_input_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,26 @@ static int input_chunk_append_raw(struct flb_input_instance *in,
flb_chunk_trace_do_input(ic);
#endif /* FLB_HAVE_CHUNK_TRACE */

/* Update 'input' metrics */
#ifdef FLB_HAVE_METRICS
if (ic->total_records > 0) {
/* timestamp */
ts = cfl_time_now();

/* fluentbit_input_records_total */
cmt_counter_add(in->cmt_records, ts, ic->added_records,
1, (char *[]) {(char *) flb_input_name(in)});

/* fluentbit_input_bytes_total */
cmt_counter_add(in->cmt_bytes, ts, buf_size,
1, (char *[]) {(char *) flb_input_name(in)});

/* OLD api */
flb_metrics_sum(FLB_METRIC_N_RECORDS, ic->added_records, in->metrics);
flb_metrics_sum(FLB_METRIC_N_BYTES, buf_size, in->metrics);
}
#endif

filtered_data_buffer = NULL;
final_data_buffer = (char *) buf;
final_data_size = buf_size;
Expand Down Expand Up @@ -1619,26 +1639,6 @@ static int input_chunk_append_raw(struct flb_input_instance *in,
ic->total_records = total_records_start;
}

/* Update 'input' metrics */
#ifdef FLB_HAVE_METRICS
if (ic->total_records > 0) {
/* timestamp */
ts = cfl_time_now();

/* fluentbit_input_records_total */
cmt_counter_add(in->cmt_records, ts, ic->added_records,
1, (char *[]) {(char *) flb_input_name(in)});

/* fluentbit_input_bytes_total */
cmt_counter_add(in->cmt_bytes, ts, buf_size,
1, (char *[]) {(char *) flb_input_name(in)});

/* OLD api */
flb_metrics_sum(FLB_METRIC_N_RECORDS, ic->added_records, in->metrics);
flb_metrics_sum(FLB_METRIC_N_BYTES, buf_size, in->metrics);
}
#endif

if (ret == -1) {
flb_error("[input chunk] error writing data from %s instance",
in->name);
Expand Down
Loading