diff --git a/include/fluent-bit/flb_input.h b/include/fluent-bit/flb_input.h index e14c685c631..fb909ca4c4b 100644 --- a/include/fluent-bit/flb_input.h +++ b/include/fluent-bit/flb_input.h @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -392,9 +393,10 @@ struct flb_input_instance { * * All metrics available for an input plugin instance. */ - struct cmt *cmt; /* parent context */ - struct cmt_counter *cmt_bytes; /* metric: input_bytes_total */ - struct cmt_counter *cmt_records; /* metric: input_records_total */ + struct cmt *cmt; /* parent context */ + struct cmt_counter *cmt_bytes; /* metric: input_bytes_total */ + struct cmt_histogram *cmt_record_sizes; /* metric: input_record_sizes */ + struct cmt_counter *cmt_records; /* metric: input_records_total */ /* is the input instance overlimit ?: 1 or 0 */ struct cmt_gauge *cmt_storage_overlimit; diff --git a/src/flb_input.c b/src/flb_input.c index 270d9882cda..82330fb5b6b 100644 --- a/src/flb_input.c +++ b/src/flb_input.c @@ -1090,6 +1090,17 @@ int flb_input_instance_init(struct flb_input_instance *ins, "Number of input bytes.", 1, (char *[]) {"name"}); cmt_counter_set(ins->cmt_bytes, ts, 0, 1, (char *[]) {name}); + struct cmt_histogram_buckets *input_record_buckets = \ + cmt_histogram_buckets_create_size((double[]){ 100, 1024, 2048, 4096, + 100 * 1024, 1024 * 1024, 4 * 1024 * 1024, + 10 * 1024 * 1024}, 8); + /* fluentbit_input_record_sizes */ + ins->cmt_record_sizes = \ + cmt_histogram_create(ins->cmt, + "fluentbit", "input", "record_sizes", + "Histogram of the size of input records", + input_record_buckets, + 1, (char *[]) {"name"}); /* fluentbit_input_records_total */ ins->cmt_records = \ diff --git a/src/flb_input_chunk.c b/src/flb_input_chunk.c index 7a6b235c0c6..cd4db9d9657 100644 --- a/src/flb_input_chunk.c +++ b/src/flb_input_chunk.c @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef FLB_HAVE_CHUNK_TRACE @@ -1672,7 +1673,8 @@ static int input_chunk_append_raw(struct flb_input_instance *in, /* fluentbit_input_bytes_total */ cmt_counter_add(in->cmt_bytes, ts, buf_size, 1, (char *[]) {(char *) flb_input_name(in)}); - + cmt_histogram_observe(in->cmt_record_sizes, 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);