fluent-plugin-td-monitoring 0.2.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ec094e544fe7a168991aa504a01ac71286e62be
4
- data.tar.gz: 27b251909dc0ebdcbdfc0724a7ef00c05fc2daaa
3
+ metadata.gz: 3617cf72d677582e10dcf7cae85badbf4f9164f8
4
+ data.tar.gz: b066629763a167e9fe70e814d9647524b18637a2
5
5
  SHA512:
6
- metadata.gz: 69d5c7872866d681fc0a57868349f0d20e9ba55adf66e0c735ab04729717a7bac9451661680f2b85586a80b71730a3fd723b488da12750c83f79db228904fa4d
7
- data.tar.gz: db39c35704a9346fd63ac005165ad24820ce6cb72a2d58759fa94c48bad1e2a2ad835fbd69e9b6abaf19d792890f7b026438c52678983acb6043d3705df21a74
6
+ metadata.gz: e392a0df7ad378881964738e721a19a560e1be4a4894e1a85189530854b5574e9206bc3a0d4f850bc850656fa63c0d2fae4419c737d83135195e6ee9510547a0
7
+ data.tar.gz: cb3b23a3321e85fe24b232f93c816a5c9939820504dc44c3aa1f12144c7d03754312f75f21bedfc170fabf3763ed3b240c41605905577a9cde3012d7c9b30d22
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 2019-04-24 version 1.0.0.
2
+
3
+ - Use v1. This is for existing users. TD monitorin will be shutdown.
4
+
1
5
  == 2018-03-26 version 0.2.4
2
6
 
3
7
  - Fix related gem version to support older ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 1.0.0
@@ -1,11 +1,13 @@
1
- module Fluent
1
+ require 'fluent/plugin/input'
2
+
3
+ module Fluent::Plugin
2
4
  require_relative 'tdms_ext_fluentd'
3
- require_relative 'out_td_counter'
5
+ #require_relative 'out_td_counter'
4
6
 
5
7
  class TDMonitorAgentInput < Input
6
- VERSION = "0.2.1"
8
+ VERSION = "0.3.0"
7
9
 
8
- Plugin.register_input('td_monitor_agent', self)
10
+ Fluent::Plugin.register_input('td_monitor_agent', self)
9
11
 
10
12
  config_param :apikey, :string, :secret => true
11
13
  config_param :emit_interval, :time, :default => 60
@@ -37,7 +39,7 @@ module Fluent
37
39
  @num_call = 0
38
40
  @call_interval = interval / 10
39
41
  @log = log
40
- super(10, repeat)
42
+ super(5, repeat)
41
43
  end
42
44
 
43
45
  def on_timer
@@ -63,8 +65,6 @@ module Fluent
63
65
  end
64
66
 
65
67
  def start
66
- Engine.set_tag_path
67
-
68
68
  @started_at = Time.now.to_i
69
69
  @monitor_agent = ExMonitorAgentInput.new
70
70
  begin
@@ -78,7 +78,7 @@ module Fluent
78
78
  @disable_node_info = true
79
79
  log.warn "Failed to get system metrics. Set 'disable_node_info' to true: #{e}"
80
80
  end
81
- @counters = collect_counters
81
+ @counters = [] #collect_counters
82
82
 
83
83
  unless register_instance_info
84
84
  log.warn "Can't register instance information at start"
@@ -1,6 +1,6 @@
1
- module Fluent
2
- require 'fluent/plugin/in_monitor_agent'
1
+ require 'fluent/plugin/in_monitor_agent'
3
2
 
3
+ module Fluent::Plugin
4
4
  class MonitorAgentInput
5
5
  def self.collect_children(pe, array=[])
6
6
  array << pe
@@ -17,29 +17,36 @@ module Fluent
17
17
 
18
18
  class ExMonitorAgentInput < MonitorAgentInput
19
19
  TD_MONITOR_INFO = MONITOR_INFO.merge(
20
- 'buffer_type' => 'buffer_type',
21
- 'buffer_path' => '@buffer.buffer_path',
22
- 'flush_interval' => '@flush_interval')
23
- %W(plugin_id config buffer_queue_length buffer_total_queued_size retry_count).each { |k|
20
+ 'buffer_type' => '@buffer_config[:@type]',
21
+ 'buffer_path' => '@buffer.path',
22
+ 'flush_interval' => '@buffer_config.flush_interval')
23
+ %W(plugin_id config buffer_queue_length buffer_total_queued_size retry_count buffer_timekeys).each { |k|
24
24
  TD_MONITOR_INFO.delete(k)
25
25
  }
26
26
 
27
27
  TD_PLUGIN_METRIC_INFO = {
28
- 'buffer_queue_length' => '@buffer.queue_size',
29
- 'buffer_queued_size' => '@buffer.total_queued_chunk_size',
30
- 'emit_count' => '@emit_count',
31
- 'retry_count' => '@num_errors'
28
+ 'buffer_queue_length' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil? && @buffer.is_a?(::Fluent::Plugin::Buffer); @buffer.queue.size },
29
+ 'buffer_queued_size' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil? && @buffer.is_a?(::Fluent::Plugin::Buffer); @buffer.stage_size + @buffer.queue_size },
30
+ 'emit_count' => ->(){ @emit_count },
31
+ 'retry_count' => ->(){
32
+ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil? && @buffer.is_a?(::Fluent::Plugin::Buffer)
33
+ begin
34
+ @retry ? @retry.steps : 0
35
+ rescue
36
+ 0
37
+ end
38
+ },
32
39
  }
33
40
 
34
41
  def get_monitor_info(pe, opts = {})
35
- obj = {'plugin_id'.freeze => pe.id_or_tag_path}
42
+ obj = {'plugin_id'.freeze => pe.plugin_id}
36
43
  conf = {
37
44
  'type'.freeze => pe.config['@type'.freeze] || pe.config['type'.freeze],
38
- 'output_plugin'.freeze => pe.is_a?(::Fluent::Output),
45
+ 'output_plugin'.freeze => pe.is_a?(::Fluent::Plugin::Output),
39
46
  'plugin_category'.freeze => plugin_category(pe)
40
47
  }
41
48
 
42
- if pe.is_a?(BufferedOutput)
49
+ if pe.is_a?(::Fluent::Plugin::Output) && pe.instance_variable_get(:@buffering)
43
50
  TD_MONITOR_INFO.each_pair { |key, code|
44
51
  begin
45
52
  v = pe.instance_eval(code)
@@ -60,7 +67,7 @@ module Fluent
60
67
  metrics = {}
61
68
  TD_PLUGIN_METRIC_INFO.each_pair { |key, code|
62
69
  begin
63
- v = pe.instance_eval(code)
70
+ v = pe.instance_exec(&code)
64
71
  unless v.nil?
65
72
  metrics[key] = {'value' => v}
66
73
  end
@@ -69,9 +76,9 @@ module Fluent
69
76
  }
70
77
 
71
78
  # set each configruration limit
72
- buffer_queue_limit = pe.instance_eval('@buffer.buffer_queue_limit')
73
- metrics['buffer_queue_length']['max'] = buffer_queue_limit
74
- metrics['buffer_queued_size']['max'] = buffer_queue_limit * pe.instance_eval('@buffer.buffer_chunk_limit')
79
+ total_size = pe.instance_eval('@buffer.total_limit_size')
80
+ metrics['buffer_queue_length']['max'] = total_size / pe.instance_eval('@buffer.chunk_limit_size')
81
+ metrics['buffer_queued_size']['max'] = total_size
75
82
 
76
83
  metrics
77
84
  end
@@ -86,91 +93,4 @@ module Fluent
86
93
  @id ? @id : @tag_path ? @tag_path : "object:#{object_id.to_s(16)}"
87
94
  end
88
95
  end
89
-
90
- if defined?(::Fluent::EventRouter) # for v0.12 or later
91
- class EngineClass
92
- def set_tag_path(prefix = '')
93
- rules = @root_agent.event_router.instance_variable_get(:@match_rules)
94
- set_tag_path_in_rules(prefix, rules)
95
-
96
- labels = @root_agent.labels
97
- labels.each { |n, label|
98
- rules = label.event_router.instance_variable_get(:@match_rules)
99
- set_tag_path_in_rules("#{prefix}/#{n}", rules)
100
- }
101
- end
102
-
103
- def set_tag_path_in_rules(prefix, rules)
104
- rules.each { |rule|
105
- tag_path = "#{prefix}/#{rule.pattern_str}"
106
- collector = rule.collector
107
- if collector.is_a?(Output)
108
- collector.tag_path = tag_path
109
- if collector.is_a?(MultiOutput) && collector.respond_to?(:outputs)
110
- set_tag_path_to_multi_output(tag_path, collector)
111
- end
112
- if collector.respond_to?(:output) && collector.output.is_a?(Output)
113
- set_tag_path_to_wrap_output(tag_path, collector)
114
- end
115
- end
116
- }
117
- end
118
- end
119
- else # for v0.10
120
- class Match
121
- alias orig_init initialize
122
- attr_reader :pattern_str
123
-
124
- def initialize(pattern_str, output)
125
- @pattern_str = pattern_str.dup
126
- orig_init(pattern_str, output)
127
- end
128
- end
129
-
130
- class EngineClass
131
- def set_tag_path(prefix = '')
132
- @matches.each { |m|
133
- if m.is_a?(Match)
134
- tag_path = "#{prefix}/#{m.pattern_str}"
135
- m.output.tag_path = tag_path
136
- if m.output.is_a?(MultiOutput) && m.output.respond_to?(:outputs)
137
- set_tag_path_to_multi_output(tag_path, m.output)
138
- end
139
- if m.output.respond_to?(:output) && m.output.output.is_a?(Output)
140
- set_tag_path_to_wrap_output(tag_path, m.output)
141
- end
142
- end
143
- }
144
- end
145
- end
146
- end
147
-
148
- # Helper methods for tag setting
149
- class EngineClass
150
- def set_tag_path_to_multi_output(prefix, multi_output)
151
- new_prefix = "#{prefix}/#{get_type_from_klass(multi_output.class)}"
152
- multi_output.outputs.each_with_index { |output, index|
153
- set_tag_path_to_output("#{new_prefix}.#{index}", output)
154
- }
155
- end
156
-
157
- def set_tag_path_to_wrap_output(prefix, wrap_output)
158
- new_prefix = "#{prefix}/#{get_type_from_klass(wrap_output.class)}"
159
- set_tag_path_to_output(new_prefix, wrap_output.output)
160
- end
161
-
162
- def set_tag_path_to_output(prefix, output)
163
- if output.is_a?(MultiOutput)
164
- set_tag_path_to_multi_output(prefix, output)
165
- else
166
- output.tag_path = "#{prefix}/#{get_type_from_klass(output.class)}"
167
- end
168
- end
169
-
170
- def get_type_from_klass(klass)
171
- Plugin.instance_variable_get(:@output).each { |name, output|
172
- return name if output == klass
173
- }
174
- end
175
- end
176
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-td-monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2019-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd