@@ -312,6 +312,11 @@ static inline int handle_output_event(uint64_t ts,
312312 flb_output_name (ins ), out_id );
313313 }
314314
315+ cmt_gauge_set (ins -> cmt_chunk_available_capacity_percent , ts ,
316+ (100 * (1.0 - (ins -> fs_backlog_chunks_size + ins -> fs_chunks_size )/
317+ ((double )ins -> total_limit_size ))),
318+ 1 , (char * []) {name });
319+
315320 flb_task_retry_clean (task , ins );
316321 flb_task_users_dec (task , FLB_TRUE );
317322 }
@@ -321,6 +326,11 @@ static inline int handle_output_event(uint64_t ts,
321326 cmt_counter_add (ins -> cmt_dropped_records , ts , task -> records ,
322327 1 , (char * []) {name });
323328
329+ cmt_gauge_set (ins -> cmt_chunk_available_capacity_percent , ts ,
330+ (100 * (1.0 - (ins -> fs_backlog_chunks_size + ins -> fs_chunks_size )/
331+ ((double )ins -> total_limit_size ))),
332+ 1 , (char * []) {name });
333+
324334 /* OLD metrics API */
325335#ifdef FLB_HAVE_METRICS
326336 flb_metrics_sum (FLB_METRIC_OUT_DROPPED_RECORDS , task -> records , ins -> metrics );
@@ -353,6 +363,11 @@ static inline int handle_output_event(uint64_t ts,
353363 cmt_counter_add (ins -> cmt_dropped_records , ts , task -> records ,
354364 1 , (char * []) {name });
355365
366+ cmt_gauge_set (ins -> cmt_chunk_available_capacity_percent , ts ,
367+ (100 * (1.0 - (ins -> fs_backlog_chunks_size + ins -> fs_chunks_size )/
368+ ((double )ins -> total_limit_size ))),
369+ 1 , (char * []) {name });
370+
356371 /* OLD metrics API */
357372#ifdef FLB_HAVE_METRICS
358373 flb_metrics_sum (FLB_METRIC_OUT_RETRY_FAILED , 1 , ins -> metrics );
@@ -409,6 +424,11 @@ static inline int handle_output_event(uint64_t ts,
409424 cmt_counter_add (ins -> cmt_retried_records , ts , task -> records ,
410425 1 , (char * []) {name });
411426
427+ cmt_gauge_set (ins -> cmt_chunk_available_capacity_percent , ts ,
428+ (100 * (1.0 - (ins -> fs_backlog_chunks_size + ins -> fs_chunks_size )/
429+ ((double )ins -> total_limit_size ))),
430+ 1 , (char * []) {name });
431+
412432 /* OLD metrics API: update the metrics since a new retry is coming */
413433#ifdef FLB_HAVE_METRICS
414434 flb_metrics_sum (FLB_METRIC_OUT_RETRY , 1 , ins -> metrics );
@@ -422,6 +442,11 @@ static inline int handle_output_event(uint64_t ts,
422442 cmt_counter_add (ins -> cmt_dropped_records , ts , task -> records ,
423443 1 , (char * []) {name });
424444
445+ cmt_gauge_set (ins -> cmt_chunk_available_capacity_percent , ts ,
446+ (100 * (1.0 - (ins -> fs_backlog_chunks_size + ins -> fs_chunks_size )/
447+ ((double )ins -> total_limit_size ))),
448+ 1 , (char * []) {name });
449+
425450 /* OLD API */
426451#ifdef FLB_HAVE_METRICS
427452 flb_metrics_sum (FLB_METRIC_OUT_ERROR , 1 , ins -> metrics );
0 commit comments