diff --git a/lib/fluent/plugin/in_prometheus_monitor.rb b/lib/fluent/plugin/in_prometheus_monitor.rb index 63a9570..7ea54ac 100644 --- a/lib/fluent/plugin/in_prometheus_monitor.rb +++ b/lib/fluent/plugin/in_prometheus_monitor.rb @@ -45,6 +45,12 @@ def configure(conf) def start super + @buffer_newest_timekey = @registry.gauge( + :fluentd_status_buffer_newest_timekey, + 'Newest timekey in buffer.') + @buffer_oldest_timekey = @registry.gauge( + :fluentd_status_buffer_oldest_timekey, + 'Oldest timekey in buffer.') buffer_queue_length = @registry.gauge( :fluentd_status_buffer_queue_length, 'Current buffer queue length.') @@ -65,11 +71,19 @@ def start def update_monitor_info @monitor_agent.plugins_info_all.each do |info| + label = labels(info) + @monitor_info.each do |name, metric| if info[name] - metric.set(labels(info), info[name]) + metric.set(label, info[name]) end end + + timekeys = info["buffer_timekeys"] + if timekeys && !timekeys.empty? + @buffer_newest_timekey.set(label, timekeys.max) + @buffer_oldest_timekey.set(label, timekeys.min) + end end end diff --git a/lib/fluent/plugin/in_prometheus_output_monitor.rb b/lib/fluent/plugin/in_prometheus_output_monitor.rb index 15f932f..1659f69 100644 --- a/lib/fluent/plugin/in_prometheus_output_monitor.rb +++ b/lib/fluent/plugin/in_prometheus_output_monitor.rb @@ -60,6 +60,12 @@ def start super @metrics = { + buffer_newest_timekey: @registry.gauge( + :fluentd_output_status_buffer_newest_timekey, + 'Newest timekey in buffer.'), + buffer_oldest_timekey: @registry.gauge( + :fluentd_output_status_buffer_oldest_timekey, + 'Oldest timekey in buffer.'), buffer_queue_length: @registry.gauge( :fluentd_output_status_buffer_queue_length, 'Current buffer queue length.'), @@ -123,6 +129,12 @@ def update_monitor_info end end + timekeys = info["buffer_timekeys"] + if timekeys && !timekeys.empty? + @metrics[:buffer_newest_timekey].set(label, timekeys.max) + @metrics[:buffer_oldest_timekey].set(label, timekeys.min) + end + if info['instance_variables'] instance_vars_info.each do |name, metric| if info['instance_variables'][name]