Class: Fluent::ExMonitorAgentInput

Inherits:
MonitorAgentInput show all
Defined in:
lib/fluent/plugin/tdms_ext_fluentd.rb

Constant Summary collapse

TD_MONITOR_INFO =
MONITOR_INFO.merge(
'buffer_type' => 'buffer_type',
'buffer_path' => '@buffer.buffer_path',
'flush_interval' => '@flush_interval')
TD_PLUGIN_METRIC_INFO =
{ 
  'buffer_queue_length' => '@buffer.queue_size',
  'buffer_queued_size' => '@buffer.total_queued_chunk_size',
  'emit_count' => '@emit_count',
  'retry_count' => '@num_errors'
}

Instance Method Summary collapse

Methods inherited from MonitorAgentInput

collect_children

Instance Method Details

#get_monitor_info(pe, opts = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fluent/plugin/tdms_ext_fluentd.rb', line 34

def get_monitor_info(pe, opts = {})
  obj = {'plugin_id'.freeze => pe.id_or_tag_path}
  conf = {
    'type'.freeze => pe.config['@type'.freeze] || pe.config['type'.freeze],
    'output_plugin'.freeze => pe.is_a?(::Fluent::Output),
    'plugin_category'.freeze => plugin_category(pe)
  }

  if pe.is_a?(BufferedOutput)
    TD_MONITOR_INFO.each_pair { |key, code|
      begin
        v = pe.instance_eval(code)
        unless v.nil?
          conf[key] = v
        end
      rescue
      end
    }
    obj['metrics'] = get_plugin_metric(pe)
  end
  obj['config'] = conf

  obj
end

#get_plugin_metric(pe) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fluent/plugin/tdms_ext_fluentd.rb', line 59

def get_plugin_metric(pe)
  metrics = {}
  TD_PLUGIN_METRIC_INFO.each_pair { |key, code|
    begin
      v = pe.instance_eval(code)
      unless v.nil?
        metrics[key] = {'value' => v}
      end
    rescue
    end
  }

  # set each configruration limit
  buffer_queue_limit = pe.instance_eval('@buffer.buffer_queue_limit')
  metrics['buffer_queue_length']['max'] = buffer_queue_limit
  metrics['buffer_queued_size']['max'] = buffer_queue_limit * pe.instance_eval('@buffer.buffer_chunk_limit')

  metrics
end