Skip to content

Commit 92b9053

Browse files
authored
input: Add ingestion_paused metrics to confirm whether an input plugin is paused or not (#8044)
1 parent 284a4eb commit 92b9053

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

include/fluent-bit/flb_input.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ struct flb_input_instance {
326326
/* is the input instance overlimit ?: 1 or 0 */
327327
struct cmt_gauge *cmt_storage_overlimit;
328328

329+
/* is the input instance paused or not ?: 1 or 0 */
330+
struct cmt_gauge *cmt_ingestion_paused;
331+
329332
/* memory bytes used by chunks */
330333
struct cmt_gauge *cmt_storage_memory_bytes;
331334

src/flb_input.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,15 @@ int flb_input_instance_init(struct flb_input_instance *ins,
970970
1, (char *[]) {"name"});
971971
cmt_counter_set(ins->cmt_records, ts, 0, 1, (char *[]) {name});
972972

973+
/* fluentbit_input_ingestion_paused */
974+
ins->cmt_ingestion_paused = \
975+
cmt_gauge_create(ins->cmt,
976+
"fluentbit", "input",
977+
"ingestion_paused",
978+
"Is the input paused or not?",
979+
1, (char *[]) {"name"});
980+
cmt_gauge_set(ins->cmt_ingestion_paused, ts, 0, 1, (char *[]) {name});
981+
973982
/* Storage Metrics */
974983
if (ctx->storage_metrics == FLB_TRUE) {
975984
/* fluentbit_input_storage_overlimit */
@@ -1670,6 +1679,24 @@ int flb_input_test_pause_resume(struct flb_input_instance *ins, int sleep_second
16701679
return 0;
16711680
}
16721681

1682+
static void flb_input_ingestion_paused(struct flb_input_instance *ins)
1683+
{
1684+
if (ins->cmt_ingestion_paused != NULL) {
1685+
/* cmetrics */
1686+
cmt_gauge_set(ins->cmt_ingestion_paused, cfl_time_now(), 1,
1687+
1, (char *[]) {flb_input_name(ins)});
1688+
}
1689+
}
1690+
1691+
static void flb_input_ingestion_resumed(struct flb_input_instance *ins)
1692+
{
1693+
if (ins->cmt_ingestion_paused != NULL) {
1694+
/* cmetrics */
1695+
cmt_gauge_set(ins->cmt_ingestion_paused, cfl_time_now(), 0,
1696+
1, (char *[]) {flb_input_name(ins)});
1697+
}
1698+
}
1699+
16731700
int flb_input_pause(struct flb_input_instance *ins)
16741701
{
16751702
/* if the instance is already paused, just return */
@@ -1689,6 +1716,8 @@ int flb_input_pause(struct flb_input_instance *ins)
16891716
}
16901717
}
16911718

1719+
flb_input_ingestion_paused(ins);
1720+
16921721
return 0;
16931722
}
16941723

@@ -1704,6 +1733,8 @@ int flb_input_resume(struct flb_input_instance *ins)
17041733
}
17051734
}
17061735

1736+
flb_input_ingestion_resumed(ins);
1737+
17071738
return 0;
17081739
}
17091740

0 commit comments

Comments
 (0)