fluent-plugin-derive 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.fluentd.lt.0.10.47 +8 -0
- data/README.md +5 -1
- data/fluent-plugin-derive.gemspec +2 -2
- data/lib/fluent/plugin/out_derive.rb +6 -1
- data/spec/out_derive_spec.rb +21 -2
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd95355aa8004a964c277475bc8716af8a1adea7
|
4
|
+
data.tar.gz: d7f05f7e00022daae25af6dbda1d926c421c6b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ac284efb825d838b1a1f6cb434fa06b5772ae8512167d606ea4bdaaa98e0b54679999893756bc9316a3ab7565a79f9f6cf9451e45b7b82ae9287e23fdac9f6
|
7
|
+
data.tar.gz: 987957ac4fbd5222ad927cce3ab77166f3a6c702c093307bca8d414ea50b7de2f1162cc1b2e2552b766ca44a482cae09556cd34dc13226ddfa7a1a47ab35a2b2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# fluent-plugin-derive
|
1
|
+
# fluent-plugin-derive, a plugin for [Fluentd](http://fluentd.org)
|
2
2
|
|
3
3
|
Calculate per second value for the increasing/decreasing value between the last and the current, like derive in RRDTool.
|
4
4
|
|
@@ -95,6 +95,10 @@ Define the expected range value. If min and/or max are specified any value outsi
|
|
95
95
|
|
96
96
|
Define the expected range value. If min and/or max are specified any value outside the defined range will be truncated.
|
97
97
|
|
98
|
+
* time_unit_division
|
99
|
+
|
100
|
+
Optional. Divide the incleased value by interval time before output. The default is `true`. Set `false` for disable dividing.
|
101
|
+
|
98
102
|
## Contributing
|
99
103
|
|
100
104
|
1. Fork it
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-derive"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.3"
|
8
8
|
spec.authors = ["Nobuhiro Nikushi"]
|
9
9
|
spec.email = ["deneb.ge@gmail.com"]
|
10
10
|
spec.description = spec.summary
|
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_runtime_dependency "fluentd"
|
21
21
|
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "rspec", '~> 2.99.0'
|
23
23
|
end
|
@@ -14,6 +14,7 @@ class Fluent::DeriveOutput < Fluent::Output
|
|
14
14
|
config_param :remove_tag_prefix, :string, :default => nil
|
15
15
|
config_param :min, :integer, :default => nil
|
16
16
|
config_param :max, :integer, :default => nil
|
17
|
+
config_param :time_unit_division, :bool, :default => true
|
17
18
|
|
18
19
|
# for test
|
19
20
|
attr_reader :key_pattern
|
@@ -155,7 +156,11 @@ class Fluent::DeriveOutput < Fluent::Output
|
|
155
156
|
log.warn "Could not calculate the rate. multiple input less than one second or minus delta of seconds on tag=#{tag}, key=#{key}"
|
156
157
|
return nil
|
157
158
|
end
|
158
|
-
|
159
|
+
if @time_unit_division
|
160
|
+
rate = (cur_value - prev_value)/(cur_time - prev_time)
|
161
|
+
else
|
162
|
+
rate = cur_value - prev_value
|
163
|
+
end
|
159
164
|
if adjustment && adjustment[0] == '*'
|
160
165
|
rate * adjustment[1]
|
161
166
|
elsif adjustment && adjustment[0] == '/'
|
data/spec/out_derive_spec.rb
CHANGED
@@ -282,6 +282,22 @@ describe Fluent::DeriveOutput do
|
|
282
282
|
}
|
283
283
|
end
|
284
284
|
|
285
|
+
context 'time_unit_division false' do
|
286
|
+
let(:config) { %[
|
287
|
+
tag rate
|
288
|
+
key1 foo
|
289
|
+
time_unit_division false
|
290
|
+
]}
|
291
|
+
before do
|
292
|
+
driver.run {
|
293
|
+
driver.emit({'foo'=> 100}, time)
|
294
|
+
driver.emit({'foo'=> 700}, time + 60)
|
295
|
+
}
|
296
|
+
end
|
297
|
+
it {
|
298
|
+
driver.emits[1].should == ['rate', time + 60, {'foo' => 600}]
|
299
|
+
}
|
300
|
+
end
|
285
301
|
|
286
302
|
end
|
287
303
|
end
|
@@ -307,17 +323,20 @@ describe Fluent::DeriveOutput do
|
|
307
323
|
if Fluent::VERSION >= "0.10.43"
|
308
324
|
context "log_level info" do
|
309
325
|
let(:config) { base_config + %[log_level info] }
|
326
|
+
subject { Fluent::VERSION <= "0.10.46" ? capture_log(log) {|log| log.debug "foobar" } : log.tap{|log| log.debug "foobar" }.logs }
|
310
327
|
|
311
328
|
it "should not contain debug level" do
|
312
|
-
|
329
|
+
should be_empty
|
313
330
|
end
|
314
331
|
end
|
315
332
|
end
|
316
333
|
|
317
334
|
context "log" do
|
318
335
|
let(:config) { base_config }
|
336
|
+
subject { Fluent::VERSION <= "0.10.46" ? capture_log(log) {|log| log.debug "foobar" } : log.tap{|log| log.debug "foobar" }.logs.first }
|
337
|
+
|
319
338
|
it "should work" do
|
320
|
-
|
339
|
+
should include("foobar")
|
321
340
|
end
|
322
341
|
end
|
323
342
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-derive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobuhiro Nikushi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.99.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.99.0
|
55
55
|
description: ''
|
56
56
|
email:
|
57
57
|
- deneb.ge@gmail.com
|
@@ -59,12 +59,13 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
64
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
65
|
- CHANGELOG.md
|
66
66
|
- Gemfile
|
67
67
|
- Gemfile.fluentd.lt.0.10.43
|
68
|
+
- Gemfile.fluentd.lt.0.10.47
|
68
69
|
- LICENSE.txt
|
69
70
|
- README.md
|
70
71
|
- Rakefile
|
@@ -83,17 +84,17 @@ require_paths:
|
|
83
84
|
- lib
|
84
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - ">="
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
91
|
requirements:
|
91
|
-
- -
|
92
|
+
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.2
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
100
|
summary: fluentd plugin to derive rate
|