Skip to content

Commit

Permalink
metrics: Add hot-reloaded metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Sep 6, 2023
1 parent e2d67ec commit 54b1b12
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/flb_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,25 @@ static int attach_build_info(struct flb_config *ctx, struct cmt *cmt, uint64_t t
return 0;
}

static int attach_hot_reload_info(struct flb_config *ctx, struct cmt *cmt, uint64_t ts,
char *hostname)
{
double val;
struct cmt_gauge *g;

g = cmt_gauge_create(cmt, "fluentbit", "", "hot_reloaded_times",
"Collect the count of hot reloaded times.",
1, (char *[]) {"hostname"});
if (!g) {
return -1;
}

val = (double) ctx->hot_reloaded_count;

cmt_gauge_set(g, ts, val, 1, (char *[]) {hostname});
return 0;
}

/* Append internal Fluent Bit metrics to context */
int flb_metrics_fluentbit_add(struct flb_config *ctx, struct cmt *cmt)
{
Expand All @@ -340,6 +359,7 @@ int flb_metrics_fluentbit_add(struct flb_config *ctx, struct cmt *cmt)
attach_uptime(ctx, cmt, ts, hostname);
attach_process_start_time_seconds(ctx, cmt, ts, hostname);
attach_build_info(ctx, cmt, ts, hostname);
attach_hot_reload_info(ctx, cmt, ts, hostname);

return 0;
}

0 comments on commit 54b1b12

Please sign in to comment.