Skip to content

Commit 2d8ff0b

Browse files
ridwanmsharifedsiper
authored andcommitted
out_stackdriver: add name label to the metrics emitted
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]>
1 parent f247c17 commit 2d8ff0b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

plugins/out_stackdriver/stackdriver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,14 +2331,15 @@ static void update_http_metrics(struct flb_stackdriver *ctx,
23312331

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

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

23392340
/* HTTP status */
23402341
if (http_status != STACKDRIVER_NET_ERROR) {
2341-
cmt_counter_inc(ctx->cmt_requests_total, ts, 1, (char *[]) {tmp});
2342+
cmt_counter_inc(ctx->cmt_requests_total, ts, 2, (char *[]) {tmp, name});
23422343
}
23432344
}
23442345
#endif

plugins/out_stackdriver/stackdriver_conf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,21 +537,21 @@ struct flb_stackdriver *flb_stackdriver_conf_create(struct flb_output_instance *
537537
"stackdriver",
538538
"requests_total",
539539
"Total number of requests.",
540-
1, (char *[]) {"status"});
540+
2, (char *[]) {"status", "name"});
541541

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

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

556556
/* OLD api */
557557
flb_metrics_add(FLB_STACKDRIVER_SUCCESSFUL_REQUESTS,

0 commit comments

Comments
 (0)