Class: Fluent::ExMonitorAgentInput

Inherits:
MonitorAgentInput show all
Defined in:
lib/fluent/plugin/fms_fluentd_ext.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' => '@error_history.size'
}

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
# File 'lib/fluent/plugin/fms_fluentd_ext.rb', line 34

def get_monitor_info(pe, opts = {})
  obj = {'plugin_id' => pe.id_or_tag_path}

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

  if conf['output_plugin'] && conf.has_key?('buffer_type')
    obj['metrics'] = get_plugin_metric(pe)
  end

  obj
end

#get_plugin_metric(pe) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fluent/plugin/fms_fluentd_ext.rb', line 56

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