fluent-plugin-numeric-monitor 0.2.0 → 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: 399b0a9e1c2a2713f6dc0dc21a8d1616360a8cf5
4
- data.tar.gz: 57e6d8d5940c160d17bc849a91183ef15769a5fc
3
+ metadata.gz: bb1a673d18f2f34ac4c1e892ea7e8778f7c508f9
4
+ data.tar.gz: 9873ee3b9e42431e1c489bd621f77fbf7dbd45d9
5
5
  SHA512:
6
- metadata.gz: c885c3d3226f88d886848788894a3f11fe09caa56c054531f63c4fcfd21b11babea8ef72f7dca7430240b2c07d54c978ab39a3ab7607e17a9c081d5289b194ea
7
- data.tar.gz: 4aca09f32e8fcae71c9003df93048f43cdb5817eaaf9d33dc1828ea031a96818aa9db761cffdbe9271721e3dbc6243c8dfa087b225a8ffb0d74d4d06f6dfb207
6
+ metadata.gz: e1194eebc1ed7de25de69d12b68d1cf5932c407149c75deb258cbc0e7fc32175c0087fe1dd641442218165a50677959dc3e84b8fcda2bd593bb91096625a5273
7
+ data.tar.gz: 5350d5ce64be10f5ed3b4ce4a37891bcea1c9b2a1627b6a4224f5e1f688fc8aa265443bd4f220fcec6ac21edb3f10b4096422513ad8079e62992cd3e546ea349
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.0.0
5
4
  - 2.1.8
6
5
  - 2.2.4
7
6
  - 2.3.0
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-numeric-monitor"
4
- gem.version = "0.2.0"
4
+ gem.version = "1.0.0"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.description = %q{Fluentd plugin to calculate min/max/avg/Xpercentile values, and emit these data as message}
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.add_development_dependency "rake"
18
18
  gem.add_development_dependency "test-unit"
19
- gem.add_runtime_dependency "fluentd", "< 0.14.0"
19
+ gem.add_runtime_dependency "fluentd", ">= 0.14.0"
20
20
  end
@@ -1,77 +1,54 @@
1
- class Fluent::NumericMonitorOutput < Fluent::Output
2
- Fluent::Plugin.register_output('numeric_monitor', self)
1
+ require 'fluent/plugin/output'
3
2
 
4
- # Define `log` method for v0.10.42 or earlier
5
- unless method_defined?(:log)
6
- define_method("log") { $log }
7
- end
3
+ class Fluent::Plugin::NumericMonitorOutput < Fluent::Plugin::Output
4
+ Fluent::Plugin.register_output('numeric_monitor', self)
8
5
 
9
- # Define `router` method of v0.12 to support v0.10.57 or earlier
10
- unless method_defined?(:router)
11
- define_method("router") { Fluent::Engine }
12
- end
6
+ helpers :event_emitter, :timer
13
7
 
14
8
  EMIT_STREAM_RECORDS = 100
15
9
 
16
- config_param :count_interval, :time, default: 60,
17
- desc: 'The interval time to monitor in seconds.'
18
- config_param :unit, default: nil do |value|
19
- case value
20
- when 'minute' then 60
21
- when 'hour' then 3600
22
- when 'day' then 86400
23
- else
24
- raise Fluent::ConfigError, "unit must be one of minute/hour/day"
25
- end
26
- end
27
- config_param :tag, :string, default: 'monitor',
28
- desc: 'The output tag.'
29
- config_param :tag_prefix, :string, default: nil,
30
- desc: <<-DESC
31
- The prefix string which will be added to the input tag.
32
- output_per_tag yes must be specified together.
33
- DESC
10
+ config_param :count_interval, :time, default: 60, desc: 'The interval time to monitor in seconds.'
11
+ config_param :unit, :enum, list: [:minute, :hour, :day], default: nil
12
+ config_param :tag, :string, default: 'monitor', desc: 'The output tag.'
13
+ config_param :aggregate, :enum, list: [:tag, :all], default: :tag, desc: "Calculate input events per tags, or all events"
34
14
 
35
15
  config_param :output_per_tag, :bool, default: false,
36
- desc: <<-DESC
37
- Emit for each input tag.
38
- tag_prefix must be specified together.
39
- DESC
40
- config_param :aggregate, default: 'tag',
41
- desc: 'Calculate in each input tag separetely, or all records in a mass.' do |val|
42
- case val
43
- when 'tag' then :tag
44
- when 'all' then :all
45
- else
46
- raise Fluent::ConfigError, "aggregate MUST be one of 'tag' or 'all'"
47
- end
48
- end
49
- config_param :input_tag_remove_prefix, :string, default: nil,
50
- desc: 'The prefix string which will be removed from the input tag.'
51
- config_param :monitor_key, :string,
52
- desc: 'The key to monitor in the event record.'
16
+ desc: 'Produce monitor result per input tags.'
17
+
18
+ config_param :monitor_key, :string, desc: 'The key to monitor in the event record.'
53
19
  config_param :output_key_prefix, :string, default: nil,
54
20
  desc: 'The prefix string which will be added to the output key.'
55
- config_param :percentiles, default: nil,
21
+ config_param :percentiles, :array, value_type: :integer, default: nil,
56
22
  desc: 'Activate the percentile monitoring. ' \
57
- 'Must be specified between 1 and 99 by integer separeted by , (comma).' do |val|
58
- values = val.split(",").map(&:to_i)
59
- if values.select{|i| i < 1 or i > 99 }.size > 0
60
- raise Fluent::ConfigError, "percentiles MUST be specified between 1 and 99 by integer"
61
- end
62
- values
63
- end
23
+ 'Must be specified between 1 and 99 by integer separeted by , (comma).'
64
24
 
65
25
  config_param :samples_limit, :integer, default: 1000000,
66
26
  desc: 'The limit number of sampling.'
67
- config_param :interval, :float, default: 0.5
27
+
28
+ config_param :tag_prefix, :string, default: nil,
29
+ desc: 'The prefix string to be added to input tags. Use with "output_per_tag yes".',
30
+ deprecated: "Use @label routing instead."
31
+ config_param :input_tag_remove_prefix, :string, default: nil,
32
+ desc: 'The prefix string which will be removed from the input tag.',
33
+ deprecated: 'Use @label routing instead.'
34
+
68
35
 
69
36
  attr_accessor :count, :last_checked
70
37
 
71
38
  def configure(conf)
39
+ label_routing_specified = conf.has_key?('@label')
40
+
72
41
  super
73
42
 
74
- @count_interval = @unit if @unit
43
+ if @unit
44
+ @count_interval = case @unit
45
+ when :minute then 60
46
+ when :hour then 3600
47
+ when :day then 86400
48
+ else
49
+ raise "unknown unit: #{@unit}"
50
+ end
51
+ end
75
52
 
76
53
  if @input_tag_remove_prefix
77
54
  @removed_prefix_string = @input_tag_remove_prefix + '.'
@@ -83,10 +60,14 @@ DESC
83
60
  @key_prefix_string = @output_key_prefix + '_'
84
61
  end
85
62
 
86
- if (@output_per_tag || @tag_prefix) && (!@output_per_tag || !@tag_prefix)
87
- raise Fluent::ConfigError, 'Specify both of output_per_tag and tag_prefix'
63
+ if @output_per_tag && (!label_routing_specified && !@tag_prefix)
64
+ raise Fluent::ConfigError, "specify @label to route output events into other <label> sections."
65
+ end
66
+ if @output_per_tag && @tag_prefix
67
+ @tag_prefix_string = @tag_prefix + '.'
68
+ else
69
+ @tag_prefix_string = nil
88
70
  end
89
- @tag_prefix_string = @tag_prefix + '.' if @output_per_tag
90
71
 
91
72
  @count = count_initialized
92
73
  @mutex = Mutex.new
@@ -94,29 +75,12 @@ DESC
94
75
 
95
76
  def start
96
77
  super
97
- start_watch
98
- end
99
78
 
100
- def shutdown
101
- super
102
- @watcher.terminate
103
- @watcher.join
104
- end
105
-
106
- def start_watch
107
- # for internal, or tests
108
- @watcher = Thread.new(&method(:watch))
109
- end
110
-
111
- def watch
112
79
  @last_checked = Fluent::Engine.now
113
- while true
114
- sleep @interval
115
- if Fluent::Engine.now - @last_checked >= @count_interval
116
- now = Fluent::Engine.now
117
- flush_emit
118
- @last_checked = now
119
- end
80
+ timer_execute(:out_numeric_counter_watcher, @count_interval) do
81
+ now = Fluent::Engine.now
82
+ flush_emit
83
+ @last_checked = now
120
84
  end
121
85
  end
122
86
 
@@ -239,7 +203,7 @@ DESC
239
203
  end
240
204
  end
241
205
 
242
- def emit(tag, es, chain)
206
+ def process(tag, es)
243
207
  min = nil
244
208
  max = nil
245
209
  sum = 0
@@ -270,7 +234,5 @@ DESC
270
234
  end
271
235
  end
272
236
  countups(tag, min, max, sum, num, sample)
273
-
274
- chain.next
275
237
  end
276
238
  end
@@ -1,4 +1,5 @@
1
1
  require 'helper'
2
+ require 'fluent/test/driver/output'
2
3
 
3
4
  class NumericMonitorOutputTest < Test::Unit::TestCase
4
5
  def setup
@@ -13,29 +14,57 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
13
14
  percentiles 80,90
14
15
  ]
15
16
 
16
- def create_driver(conf = CONFIG, tag='test.input')
17
- Fluent::Test::OutputTestDriver.new(Fluent::NumericMonitorOutput, tag).configure(conf)
17
+ def create_driver(conf = CONFIG)
18
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::NumericMonitorOutput).configure(conf)
18
19
  end
19
20
 
20
21
  def test_configure
21
22
  assert_raise(Fluent::ConfigError) {
22
- d = create_driver('')
23
+ create_driver('')
23
24
  }
24
25
  assert_raise(Fluent::ConfigError) {
25
- d = create_driver CONFIG + %[
26
+ create_driver CONFIG + %[
26
27
  output_per_tag true
27
28
  ]
28
29
  }
29
- assert_raise(Fluent::ConfigError) {
30
- d = create_driver CONFIG + %[
31
- tag_prefix prefix
30
+ assert_nothing_raised {
31
+ create_driver CONFIG + %[
32
+ output_per_tag true
33
+ @label yay
32
34
  ]
33
35
  }
34
- #TODO
36
+ d = create_driver(CONFIG)
37
+ assert_equal(60, d.instance.count_interval)
38
+ assert_equal(:minute, d.instance.unit)
39
+ assert_equal("monitor.test", d.instance.tag)
40
+ assert_nil(d.instance.tag_prefix)
41
+ assert_false(d.instance.output_per_tag)
42
+ assert_equal(:tag, d.instance.aggregate)
43
+ assert_equal("test", d.instance.input_tag_remove_prefix)
44
+ assert_equal("field1", d.instance.monitor_key)
45
+ assert_equal([80, 90], d.instance.percentiles)
35
46
  end
36
47
 
37
- def test_count_initialized
38
- #TODO
48
+ sub_test_case "#count_initialized" do
49
+ test "aggregate all" do
50
+ d = create_driver(CONFIG + %[aggregate all])
51
+ all = {"all" => {min: nil, max: nil, sum: nil, num: 0, sample: []}}
52
+ assert_equal(all, d.instance.count_initialized)
53
+ end
54
+
55
+ test "default" do
56
+ d = create_driver(CONFIG)
57
+ assert_equal({}, d.instance.count_initialized)
58
+ end
59
+
60
+ test "with keys" do
61
+ d = create_driver(CONFIG)
62
+ tag1 = "tag1"
63
+ tag2 = "tag2"
64
+ expected = {tag1 => {min: nil, max: nil, sum: nil, num: 0, sample: []},
65
+ tag2 => {min: nil, max: nil, sum: nil, num: 0, sample: []}}
66
+ assert_equal(expected, d.instance.count_initialized([tag1, tag2]))
67
+ end
39
68
  end
40
69
 
41
70
  def test_countups
@@ -54,19 +83,19 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
54
83
  end
55
84
 
56
85
  def test_emit
57
- d1 = create_driver(CONFIG, 'test.tag1')
58
- d1.run do
86
+ d1 = create_driver(CONFIG)
87
+ d1.run(default_tag: 'test.tag1') do
59
88
  10.times do
60
- d1.emit({'field1' => 0})
61
- d1.emit({'field1' => '1'})
62
- d1.emit({'field1' => 2})
63
- d1.emit({'field1' => '3'})
64
- d1.emit({'field1' => 4})
65
- d1.emit({'field1' => 5})
66
- d1.emit({'field1' => 6})
67
- d1.emit({'field1' => 7})
68
- d1.emit({'field1' => 8})
69
- d1.emit({'field1' => 9})
89
+ d1.feed({'field1' => 0})
90
+ d1.feed({'field1' => '1'})
91
+ d1.feed({'field1' => 2})
92
+ d1.feed({'field1' => '3'})
93
+ d1.feed({'field1' => 4})
94
+ d1.feed({'field1' => 5})
95
+ d1.feed({'field1' => 6})
96
+ d1.feed({'field1' => 7})
97
+ d1.feed({'field1' => 8})
98
+ d1.feed({'field1' => 9})
70
99
  end
71
100
  end
72
101
  r1 = d1.instance.flush
@@ -87,20 +116,20 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
87
116
  aggregate all
88
117
  monitor_key field1
89
118
  percentiles 80,90
90
- ], 'test.tag1')
119
+ ])
91
120
 
92
- d1.run do
121
+ d1.run(default_tag: 'test.tag1') do
93
122
  10.times do
94
- d1.emit({'field1' => 0})
95
- d1.emit({'field1' => '1'})
96
- d1.emit({'field1' => 2})
97
- d1.emit({'field1' => '3'})
98
- d1.emit({'field1' => 4})
99
- d1.emit({'field1' => 5})
100
- d1.emit({'field1' => 6})
101
- d1.emit({'field1' => 7})
102
- d1.emit({'field1' => 8})
103
- d1.emit({'field1' => 9})
123
+ d1.feed({'field1' => 0})
124
+ d1.feed({'field1' => '1'})
125
+ d1.feed({'field1' => 2})
126
+ d1.feed({'field1' => '3'})
127
+ d1.feed({'field1' => 4})
128
+ d1.feed({'field1' => 5})
129
+ d1.feed({'field1' => 6})
130
+ d1.feed({'field1' => 7})
131
+ d1.feed({'field1' => 8})
132
+ d1.feed({'field1' => 9})
104
133
  end
105
134
  end
106
135
  r1 = d1.instance.flush
@@ -118,11 +147,11 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
118
147
  unit minute
119
148
  tag testmonitor
120
149
  monitor_key x1
121
- ], 'test')
122
- d.run do
123
- d.emit({'x1' => 1})
124
- d.emit({'x1' => 2})
125
- d.emit({'x1' => 3})
150
+ ])
151
+ d.run(default_tag: 'test') do
152
+ d.feed({'x1' => 1})
153
+ d.feed({'x1' => 2})
154
+ d.feed({'x1' => 3})
126
155
  end
127
156
  r = d.instance.flush
128
157
  assert_equal 1, r['test_min']
@@ -137,27 +166,28 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
137
166
  aggregate tag
138
167
  output_per_tag true
139
168
  tag_prefix tag_prefix
140
- ], 'tag')
141
- d.run do
142
- d.tag = 'tag1'
143
- d.emit({'field1' => 1})
144
- d.emit({'field1' => 2})
145
- d.emit({'field1' => 3})
146
- d.tag = 'tag2'
147
- d.emit({'field1' => 1})
148
- d.emit({'field1' => 2})
149
- d.emit({'field1' => 3})
169
+ ])
170
+ time = Time.now.to_i
171
+ d.run(default_tag: 'tag') do
172
+ tag1 = 'tag1'
173
+ d.feed(tag1, time, {'field1' => 1})
174
+ d.feed(tag1, time, {'field1' => 2})
175
+ d.feed(tag1, time, {'field1' => 3})
176
+ tag2 = 'tag2'
177
+ d.feed(tag2, time, {'field1' => 1})
178
+ d.feed(tag2, time, {'field1' => 2})
179
+ d.feed(tag2, time, {'field1' => 3})
180
+ d.instance.flush_emit
150
181
  end
151
- d.instance.flush_emit
152
- assert_equal 2, d.emits.size
153
- tag, r = d.emits[0][0], d.emits[0][2]
182
+ assert_equal 2, d.events.size
183
+ tag, r = d.events[0][0], d.events[0][2]
154
184
  assert_equal 'tag_prefix.tag1', tag
155
185
  assert_equal 1, r['min']
156
186
  assert_equal 3, r['max']
157
187
  assert_equal 2, r['avg']
158
188
  assert_equal 6, r['sum']
159
189
  assert_equal 3, r['num']
160
- tag, r = d.emits[1][0], d.emits[1][2]
190
+ tag, r = d.events[1][0], d.events[1][2]
161
191
  assert_equal 'tag_prefix.tag2', tag
162
192
  assert_equal 1, r['min']
163
193
  assert_equal 3, r['max']
@@ -169,20 +199,21 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
169
199
  aggregate tag
170
200
  output_per_tag false
171
201
  tag output_tag
172
- ], 'tag')
173
- d.run do
174
- d.tag = 'tag1'
175
- d.emit({'field1' => 1})
176
- d.emit({'field1' => 2})
177
- d.emit({'field1' => 3})
178
- d.tag = 'tag2'
179
- d.emit({'field1' => 1})
180
- d.emit({'field1' => 2})
181
- d.emit({'field1' => 3})
202
+ ])
203
+ time = Time.now.to_i
204
+ d.run(default_tag: 'tag') do
205
+ tag1 = 'tag1'
206
+ d.feed(tag1, time, {'field1' => 1})
207
+ d.feed(tag1, time, {'field1' => 2})
208
+ d.feed(tag1, time, {'field1' => 3})
209
+ tag2 = 'tag2'
210
+ d.feed(tag2, time, {'field1' => 1})
211
+ d.feed(tag2, time, {'field1' => 2})
212
+ d.feed(tag2, time, {'field1' => 3})
213
+ d.instance.flush_emit
182
214
  end
183
- d.instance.flush_emit
184
- assert_equal 1, d.emits.size
185
- tag, r = d.emits[0][0], d.emits[0][2]
215
+ assert_equal 1, d.events.size
216
+ tag, r = d.events[0][0], d.events[0][2]
186
217
  assert_equal 'output_tag', tag
187
218
  assert_equal 1, r['tag1_min']
188
219
  assert_equal 3, r['tag1_max']
@@ -199,21 +230,22 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
199
230
  aggregate all
200
231
  output_per_tag true
201
232
  tag_prefix tag_prefix
202
- ], 'tag')
203
- d.run do
204
- d.tag = 'tag1'
205
- d.emit({'field1' => 1})
206
- d.emit({'field1' => 2})
207
- d.emit({'field1' => 3})
208
- d.tag = 'tag2'
209
- d.emit({'field1' => 1})
210
- d.emit({'field1' => 2})
211
- d.emit({'field1' => 3})
233
+ ])
234
+ time = Time.now.to_i
235
+ d.run(default_tag: 'tag') do
236
+ tag1 = 'tag1'
237
+ d.feed(tag1, time, {'field1' => 1})
238
+ d.feed(tag1, time, {'field1' => 2})
239
+ d.feed(tag1, time, {'field1' => 3})
240
+ tag2 = 'tag2'
241
+ d.feed(tag2, time, {'field1' => 1})
242
+ d.feed(tag2, time, {'field1' => 2})
243
+ d.feed(tag2, time, {'field1' => 3})
244
+ d.instance.flush_emit
212
245
  end
213
- d.instance.flush_emit
214
- assert_equal 1, d.emits.size
215
- tag = d.emits[0][0]
216
- r = d.emits[0][2]
246
+ assert_equal 1, d.events.size
247
+ tag = d.events[0][0]
248
+ r = d.events[0][2]
217
249
  assert_equal 'tag_prefix.all', tag
218
250
  assert_equal 1, r['min']
219
251
  assert_equal 3, r['max']
@@ -225,21 +257,22 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
225
257
  aggregate all
226
258
  output_per_tag false
227
259
  tag output_tag
228
- ], 'tag')
229
- d.run do
230
- d.tag = 'tag1'
231
- d.emit({'field1' => 1})
232
- d.emit({'field1' => 2})
233
- d.emit({'field1' => 3})
234
- d.tag = 'tag2'
235
- d.emit({'field1' => 1})
236
- d.emit({'field1' => 2})
237
- d.emit({'field1' => 3})
260
+ ])
261
+ time = Time.now.to_i
262
+ d.run(default_tag: 'tag') do
263
+ tag1 = 'tag1'
264
+ d.feed(tag1, time, {'field1' => 1})
265
+ d.feed(tag1, time, {'field1' => 2})
266
+ d.feed(tag1, time, {'field1' => 3})
267
+ tag2 = 'tag2'
268
+ d.feed(tag2, time, {'field1' => 1})
269
+ d.feed(tag2, time, {'field1' => 2})
270
+ d.feed(tag2, time, {'field1' => 3})
271
+ d.instance.flush_emit
238
272
  end
239
- d.instance.flush_emit
240
- assert_equal 1, d.emits.size
241
- tag = d.emits[0][0]
242
- r = d.emits[0][2]
273
+ assert_equal 1, d.events.size
274
+ tag = d.events[0][0]
275
+ r = d.events[0][2]
243
276
  assert_equal 'output_tag', tag
244
277
  assert_equal 1, r['min']
245
278
  assert_equal 3, r['max']
@@ -254,27 +287,28 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
254
287
  output_per_tag true
255
288
  tag_prefix tag_prefix
256
289
  output_key_prefix key_prefix
257
- ], 'tag')
258
- d.run do
259
- d.tag = 'tag1'
260
- d.emit({'field1' => 1})
261
- d.emit({'field1' => 2})
262
- d.emit({'field1' => 3})
263
- d.tag = 'tag2'
264
- d.emit({'field1' => 1})
265
- d.emit({'field1' => 2})
266
- d.emit({'field1' => 3})
290
+ ])
291
+ time = Time.now.to_i
292
+ d.run(default_tag: 'tag') do
293
+ tag1 = 'tag1'
294
+ d.feed(tag1, time, {'field1' => 1})
295
+ d.feed(tag1, time, {'field1' => 2})
296
+ d.feed(tag1, time, {'field1' => 3})
297
+ tag2 = 'tag2'
298
+ d.feed(tag2, time, {'field1' => 1})
299
+ d.feed(tag2, time, {'field1' => 2})
300
+ d.feed(tag2, time, {'field1' => 3})
301
+ d.instance.flush_emit
267
302
  end
268
- d.instance.flush_emit
269
- assert_equal 2, d.emits.size
270
- tag, r = d.emits[0][0], d.emits[0][2]
303
+ assert_equal 2, d.events.size
304
+ tag, r = d.events[0][0], d.events[0][2]
271
305
  assert_equal 'tag_prefix.tag1', tag
272
306
  assert_equal 1, r['key_prefix_min']
273
307
  assert_equal 3, r['key_prefix_max']
274
308
  assert_equal 2, r['key_prefix_avg']
275
309
  assert_equal 6, r['key_prefix_sum']
276
310
  assert_equal 3, r['key_prefix_num']
277
- tag, r = d.emits[1][0], d.emits[1][2]
311
+ tag, r = d.events[1][0], d.events[1][2]
278
312
  assert_equal 'tag_prefix.tag2', tag
279
313
  assert_equal 1, r['key_prefix_min']
280
314
  assert_equal 3, r['key_prefix_max']
@@ -287,20 +321,21 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
287
321
  output_per_tag false
288
322
  tag output_tag
289
323
  output_key_prefix key_prefix
290
- ], 'tag')
291
- d.run do
292
- d.tag = 'tag1'
293
- d.emit({'field1' => 1})
294
- d.emit({'field1' => 2})
295
- d.emit({'field1' => 3})
296
- d.tag = 'tag2'
297
- d.emit({'field1' => 1})
298
- d.emit({'field1' => 2})
299
- d.emit({'field1' => 3})
324
+ ])
325
+ time = Time.now.to_i
326
+ d.run(default_tag: 'tag') do
327
+ tag1 = 'tag1'
328
+ d.feed(tag1, time, {'field1' => 1})
329
+ d.feed(tag1, time, {'field1' => 2})
330
+ d.feed(tag1, time, {'field1' => 3})
331
+ tag2 = 'tag2'
332
+ d.feed(tag2, time, {'field1' => 1})
333
+ d.feed(tag2, time, {'field1' => 2})
334
+ d.feed(tag2, time, {'field1' => 3})
335
+ d.instance.flush_emit
300
336
  end
301
- d.instance.flush_emit
302
- assert_equal 1, d.emits.size
303
- tag, r = d.emits[0][0], d.emits[0][2]
337
+ assert_equal 1, d.events.size
338
+ tag, r = d.events[0][0], d.events[0][2]
304
339
  assert_equal 'output_tag', tag
305
340
  assert_equal 1, r['key_prefix_tag1_min']
306
341
  assert_equal 3, r['key_prefix_tag1_max']
@@ -318,21 +353,22 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
318
353
  output_per_tag true
319
354
  tag_prefix tag_prefix
320
355
  output_key_prefix key_prefix
321
- ], 'tag')
322
- d.run do
323
- d.tag = 'tag1'
324
- d.emit({'field1' => 1})
325
- d.emit({'field1' => 2})
326
- d.emit({'field1' => 3})
327
- d.tag = 'tag2'
328
- d.emit({'field1' => 1})
329
- d.emit({'field1' => 2})
330
- d.emit({'field1' => 3})
356
+ ])
357
+ time = Time.now.to_i
358
+ d.run(default_tag: 'tag1') do
359
+ tag1 = 'tag1'
360
+ d.feed(tag1, time, {'field1' => 1})
361
+ d.feed(tag1, time, {'field1' => 2})
362
+ d.feed(tag1, time, {'field1' => 3})
363
+ tag2 = 'tag2'
364
+ d.feed(tag2, time, {'field1' => 1})
365
+ d.feed(tag2, time, {'field1' => 2})
366
+ d.feed(tag2, time, {'field1' => 3})
367
+ d.instance.flush_emit
331
368
  end
332
- d.instance.flush_emit
333
- assert_equal 1, d.emits.size
334
- tag = d.emits[0][0]
335
- r = d.emits[0][2]
369
+ assert_equal 1, d.events.size
370
+ tag = d.events[0][0]
371
+ r = d.events[0][2]
336
372
  assert_equal 'tag_prefix.all', tag
337
373
  assert_equal 1, r['key_prefix_min']
338
374
  assert_equal 3, r['key_prefix_max']
@@ -345,21 +381,22 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
345
381
  output_per_tag false
346
382
  tag output_tag
347
383
  output_key_prefix key_prefix
348
- ], 'tag')
349
- d.run do
350
- d.tag = 'tag1'
351
- d.emit({'field1' => 1})
352
- d.emit({'field1' => 2})
353
- d.emit({'field1' => 3})
354
- d.tag = 'tag2'
355
- d.emit({'field1' => 1})
356
- d.emit({'field1' => 2})
357
- d.emit({'field1' => 3})
384
+ ])
385
+ time = Time.now.to_i
386
+ d.run(default_tag: 'tag') do
387
+ tag1 = 'tag1'
388
+ d.feed(tag1, time, {'field1' => 1})
389
+ d.feed(tag1, time, {'field1' => 2})
390
+ d.feed(tag1, time, {'field1' => 3})
391
+ tag2 = 'tag2'
392
+ d.feed(tag2, time, {'field1' => 1})
393
+ d.feed(tag2, time, {'field1' => 2})
394
+ d.feed(tag2, time, {'field1' => 3})
395
+ d.instance.flush_emit
358
396
  end
359
- d.instance.flush_emit
360
- assert_equal 1, d.emits.size
361
- tag = d.emits[0][0]
362
- r = d.emits[0][2]
397
+ assert_equal 1, d.events.size
398
+ tag = d.events[0][0]
399
+ r = d.events[0][2]
363
400
  assert_equal 'output_tag', tag
364
401
  assert_equal 1, r['key_prefix_min']
365
402
  assert_equal 3, r['key_prefix_max']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-numeric-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: fluentd
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.14.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "<"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.14.0
55
55
  description: Fluentd plugin to calculate min/max/avg/Xpercentile values, and emit