Skip to content

Commit 4788161

Browse files
committed
filter_multiline: Process truncated metrics always
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 2c38ec2 commit 4788161

File tree

1 file changed

+9
-13
lines changed
  • plugins/filter_multiline

1 file changed

+9
-13
lines changed

plugins/filter_multiline/ml.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,24 @@ static int cb_ml_init(struct flb_filter_instance *ins,
369369
"fluentbit", "filter", "emit_records_total",
370370
"Total number of emitted records",
371371
1, (char *[]) {"name"});
372+
373+
/* OLD api */
374+
flb_metrics_add(FLB_MULTILINE_METRIC_EMITTED,
375+
"emit_records", ctx->ins->metrics);
376+
#endif
377+
}
378+
/* Register a metric to count the number of emitted records */
379+
/* Truncated metrics always should be existing. */
380+
#ifdef FLB_HAVE_METRICS
372381
ctx->cmt_truncated = cmt_counter_create(ins->cmt,
373382
"fluentbit", "filter", "emit_truncated_total",
374383
"Total number of truncated occurence of multiline",
375384
1, (char *[]) {"name"});
376385

377386
/* OLD api */
378-
flb_metrics_add(FLB_MULTILINE_METRIC_EMITTED,
379-
"emit_records", ctx->ins->metrics);
380387
flb_metrics_add(FLB_MULTILINE_METRIC_TRUNCATED,
381388
"emit_truncated", ctx->ins->metrics);
382389
#endif
383-
}
384390

385391
mk_list_init(&ctx->ml_streams);
386392
mk_list_init(&ctx->split_message_packers);
@@ -846,16 +852,6 @@ static int cb_ml_filter(const void *data, size_t bytes,
846852
flb_plg_debug(ctx->ins,
847853
"could not append object from tag: %s", tag);
848854
}
849-
else if (ret == FLB_MULTILINE_OK) {
850-
#ifdef FLB_HAVE_METRICS
851-
name = (char *) flb_filter_name(ctx->ins);
852-
ts = cfl_time_now();
853-
cmt_counter_inc(ctx->cmt_emitted, ts, 1, (char *[]) {name});
854-
855-
/* old api */
856-
flb_metrics_sum(FLB_MULTILINE_METRIC_EMITTED, 1, ctx->ins->metrics);
857-
#endif
858-
}
859855
}
860856

861857
flb_log_event_decoder_destroy(&decoder);

0 commit comments

Comments
 (0)