fluent-plugin-numeric-monitor 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/example/test.conf +17 -0
- data/example/test_1s.conf +17 -0
- data/fluent-plugin-numeric-monitor.gemspec +2 -1
- data/lib/fluent/plugin/out_numeric_monitor.rb +30 -29
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9958f6c8175857684aa47425a26b7a334570e6a
|
4
|
+
data.tar.gz: 64f7c2b792cf2a14b62e4f120ece11e5f0aab977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9ea36335547a948cfd4f808224c4c55158ca350a9fc39f1a5c5135a1da19c5ded3f456440d3de21cdec05740e2c17ecb19f6efa39d8a6ac90d6d7cdccbefc4e
|
7
|
+
data.tar.gz: 030b305fc8bb4bcf9c504d683d33a1c5ca511e57c7fe97b86a276d2a5728c005119fe6c33db0f9db37e81c709a562755888bbe21a97310afc4c1c855c08f15dd
|
data/.travis.yml
CHANGED
data/example/test.conf
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<source>
|
2
|
+
@type dummy
|
3
|
+
tag testing
|
4
|
+
rate 10
|
5
|
+
auto_increment_key num
|
6
|
+
dummy [{"str": "message"}]
|
7
|
+
</source>
|
8
|
+
|
9
|
+
<match testing>
|
10
|
+
@type numeric_monitor
|
11
|
+
count_interval 10s
|
12
|
+
monitor_key num
|
13
|
+
</match>
|
14
|
+
|
15
|
+
<match monitor>
|
16
|
+
@type stdout
|
17
|
+
</match>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<source>
|
2
|
+
@type dummy
|
3
|
+
tag testing
|
4
|
+
rate 10
|
5
|
+
auto_increment_key num
|
6
|
+
dummy [{"str": "message"}]
|
7
|
+
</source>
|
8
|
+
|
9
|
+
<match testing>
|
10
|
+
@type numeric_monitor
|
11
|
+
count_interval 1s
|
12
|
+
monitor_key num
|
13
|
+
</match>
|
14
|
+
|
15
|
+
<match monitor>
|
16
|
+
@type stdout
|
17
|
+
</match>
|
@@ -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.1.
|
4
|
+
gem.version = "0.1.8"
|
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}
|
@@ -15,5 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
|
17
17
|
gem.add_development_dependency "rake"
|
18
|
+
gem.add_development_dependency "test-unit"
|
18
19
|
gem.add_runtime_dependency "fluentd"
|
19
20
|
end
|
@@ -8,13 +8,21 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
8
8
|
|
9
9
|
EMIT_STREAM_RECORDS = 100
|
10
10
|
|
11
|
-
config_param :count_interval, :time, :
|
12
|
-
config_param :unit, :
|
13
|
-
|
14
|
-
|
11
|
+
config_param :count_interval, :time, default: 60
|
12
|
+
config_param :unit, default: nil do |value|
|
13
|
+
case value
|
14
|
+
when 'minute' then 60
|
15
|
+
when 'hour' then 3600
|
16
|
+
when 'day' then 86400
|
17
|
+
else
|
18
|
+
raise Fluent::ConfigError, "unit must be one of minute/hour/day"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
config_param :tag, :string, default: 'monitor'
|
22
|
+
config_param :tag_prefix, :string, default: nil
|
15
23
|
|
16
|
-
config_param :output_per_tag, :bool, :
|
17
|
-
config_param :aggregate, :
|
24
|
+
config_param :output_per_tag, :bool, default: false
|
25
|
+
config_param :aggregate, default: 'tag' do |val|
|
18
26
|
case val
|
19
27
|
when 'tag' then :tag
|
20
28
|
when 'all' then :all
|
@@ -22,10 +30,10 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
22
30
|
raise Fluent::ConfigError, "aggregate MUST be one of 'tag' or 'all'"
|
23
31
|
end
|
24
32
|
end
|
25
|
-
config_param :input_tag_remove_prefix, :string, :
|
33
|
+
config_param :input_tag_remove_prefix, :string, default: nil
|
26
34
|
config_param :monitor_key, :string
|
27
|
-
config_param :output_key_prefix, :string, :
|
28
|
-
config_param :percentiles, :
|
35
|
+
config_param :output_key_prefix, :string, default: nil
|
36
|
+
config_param :percentiles, default: nil do |val|
|
29
37
|
values = val.split(",").map(&:to_i)
|
30
38
|
if values.select{|i| i < 1 or i > 99 }.size > 0
|
31
39
|
raise Fluent::ConfigError, "percentiles MUST be specified between 1 and 99 by integer"
|
@@ -33,22 +41,15 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
33
41
|
values
|
34
42
|
end
|
35
43
|
|
36
|
-
config_param :samples_limit, :integer, :
|
44
|
+
config_param :samples_limit, :integer, default: 1000000
|
45
|
+
config_param :interval, :float, default: 0.5
|
37
46
|
|
38
47
|
attr_accessor :count, :last_checked
|
39
48
|
|
40
49
|
def configure(conf)
|
41
50
|
super
|
42
51
|
|
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 Fluent::ConfigError, "unit must be one of minute/hour/day"
|
50
|
-
end
|
51
|
-
end
|
52
|
+
@count_interval = @unit if @unit
|
52
53
|
|
53
54
|
if @input_tag_remove_prefix
|
54
55
|
@removed_prefix_string = @input_tag_remove_prefix + '.'
|
@@ -64,7 +65,7 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
64
65
|
raise Fluent::ConfigError, 'Specify both of output_per_tag and tag_prefix'
|
65
66
|
end
|
66
67
|
@tag_prefix_string = @tag_prefix + '.' if @output_per_tag
|
67
|
-
|
68
|
+
|
68
69
|
@count = count_initialized
|
69
70
|
@mutex = Mutex.new
|
70
71
|
end
|
@@ -88,8 +89,8 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
88
89
|
def watch
|
89
90
|
@last_checked = Fluent::Engine.now
|
90
91
|
while true
|
91
|
-
sleep
|
92
|
-
if Fluent::Engine.now - @last_checked
|
92
|
+
sleep @interval
|
93
|
+
if Fluent::Engine.now - @last_checked >= @count_interval
|
93
94
|
now = Fluent::Engine.now
|
94
95
|
flush_emit
|
95
96
|
@last_checked = now
|
@@ -101,15 +102,15 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
101
102
|
# counts['tag'] = {:min => num, :max => num, :sum => num, :num => num [, :sample => [....]]}
|
102
103
|
if @aggregate == :all
|
103
104
|
if @percentiles
|
104
|
-
{'all' => {:
|
105
|
+
{'all' => {min: nil, max: nil, sum: nil, num: 0, sample: []}}
|
105
106
|
else
|
106
|
-
{'all' => {:
|
107
|
+
{'all' => {min: nil, max: nil, sum: nil, num: 0}}
|
107
108
|
end
|
108
109
|
elsif keys
|
109
110
|
values = if @percentiles
|
110
|
-
Array.new(keys.length) {|i| {:
|
111
|
+
Array.new(keys.length) {|i| {min: nil, max: nil, sum: nil, num: 0, sample: []}}
|
111
112
|
else
|
112
|
-
Array.new(keys.length) {|i| {:
|
113
|
+
Array.new(keys.length) {|i| {min: nil, max: nil, sum: nil, num: 0}}
|
113
114
|
end
|
114
115
|
Hash[[keys, values].transpose]
|
115
116
|
else
|
@@ -193,8 +194,8 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
193
194
|
end
|
194
195
|
|
195
196
|
@mutex.synchronize do
|
196
|
-
c = (@count[tag] ||= {:
|
197
|
-
|
197
|
+
c = (@count[tag] ||= {min: nil, max: nil, sum: nil, num: 0})
|
198
|
+
|
198
199
|
if c[:min].nil? or c[:min] > min
|
199
200
|
c[:min] = min
|
200
201
|
end
|
@@ -208,7 +209,7 @@ class Fluent::NumericMonitorOutput < Fluent::Output
|
|
208
209
|
c[:sample] ||= []
|
209
210
|
if c[:sample].size + sample.size > @samples_limit
|
210
211
|
(c[:sample].size + sample.size - @samples_limit).times do
|
211
|
-
c[:sample].delete_at(rand(c[:sample].size))
|
212
|
+
c[:sample].delete_at(rand(c[:sample].size))
|
212
213
|
end
|
213
214
|
end
|
214
215
|
c[:sample] += sample
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-numeric-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: fluentd
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,8 @@ files:
|
|
52
66
|
- LICENSE.txt
|
53
67
|
- README.md
|
54
68
|
- Rakefile
|
69
|
+
- example/test.conf
|
70
|
+
- example/test_1s.conf
|
55
71
|
- fluent-plugin-numeric-monitor.gemspec
|
56
72
|
- lib/fluent/plugin/out_numeric_monitor.rb
|
57
73
|
- test/helper.rb
|
@@ -76,10 +92,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
92
|
version: '0'
|
77
93
|
requirements: []
|
78
94
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.5
|
80
96
|
signing_key:
|
81
97
|
specification_version: 4
|
82
98
|
summary: Fluentd plugin to calculate min/max/avg/Xpercentile values
|
83
99
|
test_files:
|
84
100
|
- test/helper.rb
|
85
101
|
- test/plugin/test_out_numeric_monitor.rb
|
102
|
+
has_rdoc:
|