Skip to content

Commit

Permalink
out_stackdriver: add name label to the metrics emitted
Browse files Browse the repository at this point in the history
This change adds the `name` label to the metrics. When used with multiple
of the same exporter, the metrics from each of them become
indistinguishable from the others. This leads to problems when ingesting
metrics. FOr example the `prometheus` reciever in Open Telemetry will
assume they are one and the same metric nad will replace existing data
points with later ones.

Signed-off-by: Ridwan Sharif <[email protected]>
  • Loading branch information
ridwanmsharif authored and edsiper committed Aug 17, 2022
1 parent f247c17 commit 2d8ff0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions plugins/out_stackdriver/stackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,14 +2331,15 @@ static void update_http_metrics(struct flb_stackdriver *ctx,

/* convert status to string format */
snprintf(tmp, sizeof(tmp) - 1, "%i", http_status);
char *name = (char *) flb_output_name(ctx->ins);

/* processed records total */
cmt_counter_add(ctx->cmt_proc_records_total, ts, event_chunk->total_events,
1, (char *[]) {tmp});
2, (char *[]) {tmp, name});

/* HTTP status */
if (http_status != STACKDRIVER_NET_ERROR) {
cmt_counter_inc(ctx->cmt_requests_total, ts, 1, (char *[]) {tmp});
cmt_counter_inc(ctx->cmt_requests_total, ts, 2, (char *[]) {tmp, name});
}
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions plugins/out_stackdriver/stackdriver_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,21 +537,21 @@ struct flb_stackdriver *flb_stackdriver_conf_create(struct flb_output_instance *
"stackdriver",
"requests_total",
"Total number of requests.",
1, (char *[]) {"status"});
2, (char *[]) {"status", "name"});

ctx->cmt_proc_records_total = cmt_counter_create(ins->cmt,
"fluentbit",
"stackdriver",
"proc_records_total",
"Total number of processed records.",
1, (char *[]) {"status"});
2, (char *[]) {"status", "name"});

ctx->cmt_retried_records_total = cmt_counter_create(ins->cmt,
"fluentbit",
"stackdriver",
"retried_records_total",
"Total number of retried records.",
1, (char *[]) {"status"});
2, (char *[]) {"status", "name"});

/* OLD api */
flb_metrics_add(FLB_STACKDRIVER_SUCCESSFUL_REQUESTS,
Expand Down

0 comments on commit 2d8ff0b

Please sign in to comment.