Skip to content

Commit

Permalink
input: Add any overlimit metrics to confirm whether an input plugin i…
Browse files Browse the repository at this point in the history
…s paused or not

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Oct 16, 2023
1 parent 8401076 commit 5e51d60
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ struct flb_input_instance {
/* is the input instance overlimit ?: 1 or 0 */
struct cmt_gauge *cmt_storage_overlimit;

/* is the input instance paused or not ?: 1 or 0 */
struct cmt_gauge *cmt_any_overlimit;

/* memory bytes used by chunks */
struct cmt_gauge *cmt_storage_memory_bytes;

Expand Down
37 changes: 37 additions & 0 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,15 @@ int flb_input_instance_init(struct flb_input_instance *ins,
1, (char *[]) {"name"});
cmt_counter_set(ins->cmt_records, ts, 0, 1, (char *[]) {name});

/* fluentbit_input_any_overlimit */
ins->cmt_any_overlimit = \
cmt_gauge_create(ins->cmt,
"fluentbit", "input",
"any_overlimit",
"Is the input paused or not?",
1, (char *[]) {"name"});
cmt_gauge_set(ins->cmt_any_overlimit, ts, 0, 1, (char *[]) {name});

/* Storage Metrics */
if (ctx->storage_metrics == FLB_TRUE) {
/* fluentbit_input_storage_overlimit */
Expand Down Expand Up @@ -1670,6 +1679,30 @@ int flb_input_test_pause_resume(struct flb_input_instance *ins, int sleep_second
return 0;
}

static void flb_input_any_overlimit_paused(struct flb_input_instance *ins)
{
uint64_t ts;

/* current time */
ts = cfl_time_now();

/* cmetrics */
cmt_gauge_set(ins->cmt_any_overlimit, ts, 1,
1, (char *[]) {ins->name});
}

static void flb_input_any_overlimit_resumed(struct flb_input_instance *ins)
{
uint64_t ts;

/* current time */
ts = cfl_time_now();

/* cmetrics */
cmt_gauge_set(ins->cmt_any_overlimit, ts, 0,
1, (char *[]) {ins->name});
}

int flb_input_pause(struct flb_input_instance *ins)
{
/* if the instance is already paused, just return */
Expand All @@ -1689,6 +1722,8 @@ int flb_input_pause(struct flb_input_instance *ins)
}
}

flb_input_any_overlimit_paused(ins);

return 0;
}

Expand All @@ -1704,6 +1739,8 @@ int flb_input_resume(struct flb_input_instance *ins)
}
}

flb_input_any_overlimit_resumed(ins);

return 0;
}

Expand Down

0 comments on commit 5e51d60

Please sign in to comment.