fluent-plugin-numeric-monitor 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/fluent-plugin-numeric-monitor.gemspec +2 -2
- data/lib/fluent/plugin/out_numeric_monitor.rb +44 -82
- data/test/plugin/test_out_numeric_monitor.rb +186 -149
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb1a673d18f2f34ac4c1e892ea7e8778f7c508f9
|
4
|
+
data.tar.gz: 9873ee3b9e42431e1c489bd621f77fbf7dbd45d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1194eebc1ed7de25de69d12b68d1cf5932c407149c75deb258cbc0e7fc32175c0087fe1dd641442218165a50677959dc3e84b8fcda2bd593bb91096625a5273
|
7
|
+
data.tar.gz: 5350d5ce64be10f5ed3b4ce4a37891bcea1c9b2a1627b6a4224f5e1f688fc8aa265443bd4f220fcec6ac21edb3f10b4096422513ad8079e62992cd3e546ea349
|
data/.travis.yml
CHANGED
@@ -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.
|
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", "
|
19
|
+
gem.add_runtime_dependency "fluentd", ">= 0.14.0"
|
20
20
|
end
|
@@ -1,77 +1,54 @@
|
|
1
|
-
|
2
|
-
Fluent::Plugin.register_output('numeric_monitor', self)
|
1
|
+
require 'fluent/plugin/output'
|
3
2
|
|
4
|
-
|
5
|
-
|
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
|
-
|
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
|
-
|
18
|
-
config_param :
|
19
|
-
|
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:
|
37
|
-
|
38
|
-
|
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).'
|
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
|
-
|
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
|
-
|
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
|
87
|
-
raise Fluent::ConfigError,
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
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
|
17
|
-
Fluent::Test::
|
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
|
-
|
23
|
+
create_driver('')
|
23
24
|
}
|
24
25
|
assert_raise(Fluent::ConfigError) {
|
25
|
-
|
26
|
+
create_driver CONFIG + %[
|
26
27
|
output_per_tag true
|
27
28
|
]
|
28
29
|
}
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
assert_nothing_raised {
|
31
|
+
create_driver CONFIG + %[
|
32
|
+
output_per_tag true
|
33
|
+
@label yay
|
32
34
|
]
|
33
35
|
}
|
34
|
-
|
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
|
-
|
38
|
-
|
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
|
58
|
-
d1.run do
|
86
|
+
d1 = create_driver(CONFIG)
|
87
|
+
d1.run(default_tag: 'test.tag1') do
|
59
88
|
10.times do
|
60
|
-
d1.
|
61
|
-
d1.
|
62
|
-
d1.
|
63
|
-
d1.
|
64
|
-
d1.
|
65
|
-
d1.
|
66
|
-
d1.
|
67
|
-
d1.
|
68
|
-
d1.
|
69
|
-
d1.
|
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
|
-
]
|
119
|
+
])
|
91
120
|
|
92
|
-
d1.run do
|
121
|
+
d1.run(default_tag: 'test.tag1') do
|
93
122
|
10.times do
|
94
|
-
d1.
|
95
|
-
d1.
|
96
|
-
d1.
|
97
|
-
d1.
|
98
|
-
d1.
|
99
|
-
d1.
|
100
|
-
d1.
|
101
|
-
d1.
|
102
|
-
d1.
|
103
|
-
d1.
|
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
|
-
]
|
122
|
-
d.run do
|
123
|
-
d.
|
124
|
-
d.
|
125
|
-
d.
|
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
|
-
]
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
d.
|
145
|
-
d.
|
146
|
-
d.
|
147
|
-
|
148
|
-
d.
|
149
|
-
d.
|
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.
|
152
|
-
|
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.
|
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
|
-
]
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
d.
|
177
|
-
d.
|
178
|
-
d.
|
179
|
-
|
180
|
-
d.
|
181
|
-
d.
|
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.
|
184
|
-
|
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
|
-
]
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
d.
|
207
|
-
d.
|
208
|
-
d.
|
209
|
-
|
210
|
-
d.
|
211
|
-
d.
|
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.
|
214
|
-
|
215
|
-
|
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
|
-
]
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
d.
|
233
|
-
d.
|
234
|
-
d.
|
235
|
-
|
236
|
-
d.
|
237
|
-
d.
|
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.
|
240
|
-
|
241
|
-
|
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
|
-
]
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
d.
|
262
|
-
d.
|
263
|
-
d.
|
264
|
-
|
265
|
-
d.
|
266
|
-
d.
|
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.
|
269
|
-
|
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.
|
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
|
-
]
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
d.
|
295
|
-
d.
|
296
|
-
d.
|
297
|
-
|
298
|
-
d.
|
299
|
-
d.
|
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.
|
302
|
-
|
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
|
-
]
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
d.
|
326
|
-
d.
|
327
|
-
d.
|
328
|
-
|
329
|
-
d.
|
330
|
-
d.
|
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.
|
333
|
-
|
334
|
-
|
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
|
-
]
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
d.
|
353
|
-
d.
|
354
|
-
d.
|
355
|
-
|
356
|
-
d.
|
357
|
-
d.
|
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.
|
360
|
-
|
361
|
-
|
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.
|
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
|