Skip to content

Commit ef6798a

Browse files
committed
input: add new ring buffer metrics
When input plugins runs in threaded mode, they use a ring buffer to communicate with the engine. This patch adds new metrics to track the behavior of the input ring buffer, enabling better observability and troubleshooting in high-load or threaded environments. The following counters are now registered per input instance: - fluentbit_input_ring_buffer_writes_total: Number of successful ring buffer writes - fluentbit_input_ring_buffer_retries_total: Number of retry attempts due to saturation - fluentbit_input_ring_buffer_retry_failures_total: Number of failed retries (after limit hit) Example from Prometheus endpoint: # HELP fluentbit_input_ring_buffer_writes_total Number of ring buffer writes. # TYPE fluentbit_input_ring_buffer_writes_total counter fluentbit_input_ring_buffer_writes_total{name="syslog.0"} 15000 # HELP fluentbit_input_ring_buffer_retries_total Number of ring buffer retries. # TYPE fluentbit_input_ring_buffer_retries_total counter fluentbit_input_ring_buffer_retries_total{name="syslog.0"} 820 # HELP fluentbit_input_ring_buffer_retry_failures_total Number of ring buffer retry failures. # TYPE fluentbit_input_ring_buffer_retry_failures_total counter fluentbit_input_ring_buffer_retry_failures_total{name="syslog.0"} 5 Signed-off-by: Eduardo Silva <[email protected]>
1 parent 2eab0ad commit ef6798a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

include/fluent-bit/flb_input.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@ struct flb_input_instance {
426426
struct cmt_counter *cmt_memrb_dropped_chunks;
427427
struct cmt_counter *cmt_memrb_dropped_bytes;
428428

429+
/* ring buffer 'write' metrics */
430+
struct cmt_counter *cmt_ring_buffer_writes;
431+
struct cmt_counter *cmt_ring_buffer_retries;
432+
struct cmt_counter *cmt_ring_buffer_retry_failures;
433+
429434
/*
430435
* Indexes for generated chunks: simple hash tables that keeps the latest
431436
* available chunks for writing data operations. This optimizes the

src/flb_input.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,34 @@ int flb_input_instance_init(struct flb_input_instance *ins,
12371237
cmt_counter_set(ins->cmt_memrb_dropped_bytes, ts, 0, 1, (char *[]) {name});
12381238
}
12391239

1240+
/* fluentbit_input_ring_buffer_writes_total */
1241+
ins->cmt_ring_buffer_writes = \
1242+
cmt_counter_create(ins->cmt,
1243+
"fluentbit", "input",
1244+
"ring_buffer_writes_total",
1245+
"Number of ring buffer writes.",
1246+
1, (char *[]) {"name"});
1247+
cmt_gauge_set(ins->cmt_ring_buffer_writes, ts, 0, 1, (char *[]) {name});
1248+
1249+
/* fluentbit_input_ring_buffer_retries_total */
1250+
ins->cmt_ring_buffer_retries = \
1251+
cmt_counter_create(ins->cmt,
1252+
"fluentbit", "input",
1253+
"ring_buffer_retries_total",
1254+
"Number of ring buffer retries.",
1255+
1, (char *[]) {"name"});
1256+
cmt_counter_set(ins->cmt_ring_buffer_retries, ts, 0, 1, (char *[]) {name});
1257+
1258+
1259+
/* fluentbit_input_ring_buffer_retry_failures_total */
1260+
ins->cmt_ring_buffer_retry_failures = \
1261+
cmt_counter_create(ins->cmt,
1262+
"fluentbit", "input",
1263+
"ring_buffer_retry_failures_total",
1264+
"Number of ring buffer retry failures.",
1265+
1, (char *[]) {"name"});
1266+
cmt_counter_set(ins->cmt_ring_buffer_retry_failures, ts, 0, 1, (char *[]) {name});
1267+
12401268
/* OLD Metrics */
12411269
ins->metrics = flb_metrics_create(name);
12421270
if (ins->metrics) {

0 commit comments

Comments
 (0)