Skip to content

Commit f190e0a

Browse files
input: add new histogram metric for size of records
1 parent 9def01d commit f190e0a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

include/fluent-bit/flb_input.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <fluent-bit/flb_pthread.h>
5252

5353
#include <cmetrics/cmetrics.h>
54+
#include <cmetrics/cmt_histogram.h>
5455
#include <monkey/mk_core.h>
5556
#include <msgpack.h>
5657
#include <inttypes.h>
@@ -392,9 +393,10 @@ struct flb_input_instance {
392393
*
393394
* All metrics available for an input plugin instance.
394395
*/
395-
struct cmt *cmt; /* parent context */
396-
struct cmt_counter *cmt_bytes; /* metric: input_bytes_total */
397-
struct cmt_counter *cmt_records; /* metric: input_records_total */
396+
struct cmt *cmt; /* parent context */
397+
struct cmt_counter *cmt_bytes; /* metric: input_bytes_total */
398+
struct cmt_histogram *cmt_record_sizes; /* metric: input_record_sizes */
399+
struct cmt_counter *cmt_records; /* metric: input_records_total */
398400

399401
/* is the input instance overlimit ?: 1 or 0 */
400402
struct cmt_gauge *cmt_storage_overlimit;

src/flb_input.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,17 @@ int flb_input_instance_init(struct flb_input_instance *ins,
10901090
"Number of input bytes.",
10911091
1, (char *[]) {"name"});
10921092
cmt_counter_set(ins->cmt_bytes, ts, 0, 1, (char *[]) {name});
1093+
struct cmt_histogram_buckets *input_record_buckets = \
1094+
cmt_histogram_buckets_create_size((double[]){ 100, 1024, 2048, 4096,
1095+
100 * 1024, 1024 * 1024, 4 * 1024 * 1024,
1096+
10 * 1024 * 1024}, 8);
1097+
/* fluentbit_input_record_sizes */
1098+
ins->cmt_record_sizes = \
1099+
cmt_histogram_create(ins->cmt,
1100+
"fluentbit", "input", "record_sizes",
1101+
"Histogram of the size of input records",
1102+
input_record_buckets,
1103+
1, (char *[]) {"name"});
10931104

10941105
/* fluentbit_input_records_total */
10951106
ins->cmt_records = \

src/flb_input_chunk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <fluent-bit/flb_ring_buffer.h>
3939
#include <chunkio/chunkio.h>
4040
#include <monkey/mk_core.h>
41+
#include <cmetrics/cmt_histogram.h>
4142

4243

4344
#ifdef FLB_HAVE_CHUNK_TRACE
@@ -1672,7 +1673,8 @@ static int input_chunk_append_raw(struct flb_input_instance *in,
16721673
/* fluentbit_input_bytes_total */
16731674
cmt_counter_add(in->cmt_bytes, ts, buf_size,
16741675
1, (char *[]) {(char *) flb_input_name(in)});
1675-
1676+
cmt_histogram_observe(in->cmt_record_sizes, ts, buf_size,
1677+
1, (char *[]){(char *) flb_input_name(in)});
16761678
/* OLD api */
16771679
flb_metrics_sum(FLB_METRIC_N_RECORDS, ic->added_records, in->metrics);
16781680
flb_metrics_sum(FLB_METRIC_N_BYTES, buf_size, in->metrics);

0 commit comments

Comments
 (0)