Skip to content

Commit

Permalink
in_node_exporter_metrics: collect metrics at startup(#8368) (#8370)
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored Jan 13, 2024
1 parent f8bd0ce commit 78c8aa4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions plugins/in_node_exporter_metrics/ne.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ static int activate_collector(struct flb_ne *ctx, struct flb_config *config,
}
coll->activated = FLB_TRUE;

if (coll->cb_update) {
coll->cb_update(ctx->ins, config, ctx);
}

return 0;
}

Expand Down Expand Up @@ -206,18 +210,6 @@ static int in_ne_init(struct flb_input_instance *in,
/* Associate context with the instance */
flb_input_set_context(in, ctx);

/* Create the collector */
ret = flb_input_set_collector_time(in,
cb_ne_collect,
ctx->scrape_interval, 0,
config);
if (ret == -1) {
flb_plg_error(ctx->ins,
"could not set collector for Node Exporter Metrics plugin");
return -1;
}
ctx->coll_fd = ret;

/* Check and initialize enabled metrics */
if (ctx->metrics) {
mk_list_foreach(head, ctx->metrics) {
Expand Down Expand Up @@ -247,6 +239,18 @@ static int in_ne_init(struct flb_input_instance *in,
return -1;
}

/* Create the collector */
ret = flb_input_set_collector_time(in,
cb_ne_collect,
ctx->scrape_interval, 0,
config);
if (ret == -1) {
flb_plg_error(ctx->ins,
"could not set collector for Node Exporter Metrics plugin");
return -1;
}
ctx->coll_fd = ret;

return 0;
}

Expand Down

0 comments on commit 78c8aa4

Please sign in to comment.