Skip to content

Commit f18bd12

Browse files
committed
output: add metrics for dropped oldest chunk count
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent cef2f65 commit f18bd12

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/fluent/plugin/output.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def initialize
190190
@rollback_count_metrics = nil
191191
@flush_time_count_metrics = nil
192192
@slow_flush_count_metrics = nil
193+
@drop_oldest_chunk_count_metrics = nil
193194
@enable_size_metrics = false
194195

195196
# How to process events is decided here at once, but it will be decided in delayed way on #configure & #start
@@ -259,6 +260,7 @@ def configure(conf)
259260
@rollback_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "rollback_count", help_text: "Number of rollbacking operations")
260261
@flush_time_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "flush_time_count", help_text: "Count of flush time")
261262
@slow_flush_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "slow_flush_count", help_text: "Count of slow flush occurred time(s)")
263+
@drop_oldest_chunk_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "drop_oldest_chunk_count", help_text: "Number of count that old chunk were discarded with drop_oldest_chunk")
262264

263265
if has_buffer_section
264266
unless implement?(:buffered) || implement?(:delayed_commit)
@@ -977,6 +979,7 @@ def write_guard(&block)
977979
if oldest
978980
log.warn "dropping oldest chunk to make space after buffer overflow", chunk_id: dump_unique_id_hex(oldest.unique_id)
979981
@buffer.purge_chunk(oldest.unique_id)
982+
@drop_oldest_chunk_metrics.inc
980983
else
981984
log.error "no queued chunks to be dropped for drop_oldest_chunk"
982985
end
@@ -1575,6 +1578,7 @@ def statistics
15751578
'rollback_count' => @rollback_count_metrics.get,
15761579
'slow_flush_count' => @slow_flush_count_metrics.get,
15771580
'flush_time_count' => @flush_time_count_metrics.get,
1581+
'drop_oldest_chunk_count' => @drop_oldest_chunk_count_metrics.get,
15781582
}
15791583

15801584
if @buffer && @buffer.respond_to?(:statistics)

test/plugin/test_output.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def waiting(seconds)
227227
@i.configure(config_element())
228228

229229
%w[num_errors_metrics emit_count_metrics emit_size_metrics emit_records_metrics write_count_metrics
230-
write_secondary_count_metrics rollback_count_metrics flush_time_count_metrics slow_flush_count_metrics].each do |metric_name|
230+
write_secondary_count_metrics rollback_count_metrics flush_time_count_metrics slow_flush_count_metrics
231+
drop_oldest_chunk_count_metrics].each do |metric_name|
231232
assert_true @i.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
232233
end
233234

@@ -241,6 +242,7 @@ def waiting(seconds)
241242
assert_equal 0, @i.rollback_count
242243
assert_equal 0, @i.flush_time_count
243244
assert_equal 0, @i.slow_flush_count
245+
assert_equal 0, @i.drop_oldest_chunk_count
244246
end
245247

246248
data(:new_api => :chunk,

0 commit comments

Comments
 (0)