Skip to content

Commit 3b11f8c

Browse files
committed
output: add metrics for number of stored chunks in secondary
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent a3f4c82 commit 3b11f8c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/fluent/plugin/output.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def initialize
213213
@rollback_count_metrics = nil
214214
@flush_time_count_metrics = nil
215215
@slow_flush_count_metrics = nil
216+
@secondary_chunk_count_metrics = nil
216217
@enable_size_metrics = false
217218

218219
# How to process events is decided here at once, but it will be decided in delayed way on #configure & #start
@@ -281,6 +282,7 @@ def configure(conf)
281282
@rollback_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "rollback_count", help_text: "Number of rollbacking operations")
282283
@flush_time_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "flush_time_count", help_text: "Count of flush time")
283284
@slow_flush_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "slow_flush_count", help_text: "Count of slow flush occurred time(s)")
285+
@secondary_chunk_count_metrics = metrics_create(namespace: "fluentd", subsystem: "output", name: "secondary_chunk_count", help_text: "Number of stored chunks in secondary")
284286

285287
if has_buffer_section
286288
unless implement?(:buffered) || implement?(:delayed_commit)
@@ -1117,6 +1119,7 @@ def commit_write(chunk_id, delayed: @delayed_commit, secondary: false)
11171119
if @retry # success to flush chunks in retries
11181120
if secondary
11191121
log.warn "retry succeeded by secondary.", chunk_id: dump_unique_id_hex(chunk_id)
1122+
@secondary_chunk_count_metrics.inc
11201123
else
11211124
log.warn "retry succeeded.", chunk_id: dump_unique_id_hex(chunk_id)
11221125
end
@@ -1594,6 +1597,7 @@ def statistics
15941597
'rollback_count' => @rollback_count_metrics.get,
15951598
'slow_flush_count' => @slow_flush_count_metrics.get,
15961599
'flush_time_count' => @flush_time_count_metrics.get,
1600+
'secondary_chunk_count' => @secondary_chunk_count_metrics.get,
15971601
}
15981602

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

test/test_plugin_classes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def initialize
154154
@rollback_count_metrics = FluentTest::FluentTestCounterMetrics.new
155155
@flush_time_count_metrics = FluentTest::FluentTestCounterMetrics.new
156156
@slow_flush_count_metrics = FluentTest::FluentTestCounterMetrics.new
157+
@secondary_chunk_count_metrics = FluentTest::FluentTestCounterMetrics.new
157158
end
158159

159160
attr_reader :events
@@ -284,6 +285,7 @@ def initialize
284285
@rollback_count_metrics = FluentTest::FluentTestCounterMetrics.new
285286
@flush_time_count_metrics = FluentTest::FluentTestCounterMetrics.new
286287
@slow_flush_count_metrics = FluentTest::FluentTestCounterMetrics.new
288+
@secondary_chunk_count_metrics = FluentTest::FluentTestCounterMetrics.new
287289
end
288290

289291
def format(tag, time, record)

0 commit comments

Comments
 (0)