fluent-plugin-anomalydetect 0.1.1 → 0.1.2

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: 00950f80d0252742704254c65f1f20a145fe967d
4
- data.tar.gz: 7c9fd9003e576cbb8a51006ef7c5fad2a8b8d626
3
+ metadata.gz: 5dc986d4d340cf2115aaf591724f1f7215dbbbd8
4
+ data.tar.gz: 9cb4fcb75b4500f544a1d81e1159e60ffdc956d3
5
5
  SHA512:
6
- metadata.gz: e0ca5a907d709856442ba77c26315bcb3d8777484e1920389f0cd1c20889bbd8625a4ad9087dd6ddaf8b03cf38815f64f84a368d2577d9a7c3e02451e4c16da8
7
- data.tar.gz: 89b8175c1797a2800e92710fd9f84b0177239e8ab40dd27b7e9624a3786bb81bc813b98b0011d33503f3f09fac5c1301ed9f17fb401194417bfc922cb86668fc
6
+ metadata.gz: d414c7d4fc72620c9b35ec135145b67d7042315e3e0280339c0a5e08526c0da9ec104432b60321ff761c00fae1db63e56fb75dd4f758979a604910b41ba74067
7
+ data.tar.gz: f48841a679ffe543fbba58bdf27443653f50ed0e144f94055562edff663f9e30aa5782f1cc7ad62ace7b9cb922f13c5c509ce622ac669e44cb55d5ab9e919b61
data/README.rdoc CHANGED
@@ -82,6 +82,14 @@ If "store_file" option was specified, a historical stat will be stored to the fi
82
82
 
83
83
  If "threshold" option was specified, plugin only ouput when the anomalyscore is more than threshold.
84
84
 
85
+ <match access.**>
86
+ type anomalydetect
87
+ ...
88
+ trend up
89
+ </match>
90
+
91
+ If "trend" option was specified, plugin only ouput when the input data tends to up (or down).
92
+
85
93
  == Theory
86
94
  "データマイニングによる異常検知" http://amzn.to/XHXNun
87
95
 
@@ -3,7 +3,7 @@ lib = File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-anomalydetect"
6
- gem.version = "0.1.1"
6
+ gem.version = "0.1.2"
7
7
  gem.authors = ["Muddy Dixon"]
8
8
  gem.email = ["muddydixon@gmail.com"]
9
9
  gem.description = %q{detect anomal sequential input casually}
@@ -2,6 +2,7 @@
2
2
  module Fluent
3
3
  class ChangeFinder
4
4
  require 'matrix'
5
+ attr_reader :mu
5
6
 
6
7
  def initialize(term, r)
7
8
  @term = term
@@ -15,6 +15,16 @@ module Fluent
15
15
  config_param :target, :string, :default => nil
16
16
  config_param :store_file, :string, :default => nil
17
17
  config_param :threshold, :float, :default => -1.0
18
+ config_param :trend, :default => nil do |val|
19
+ case val.downcase
20
+ when 'up'
21
+ :up
22
+ when 'down'
23
+ :down
24
+ else
25
+ raise ConfigError, "out_anomaly treand should be 'up' or 'down'"
26
+ end
27
+ end
18
28
 
19
29
  attr_accessor :outlier
20
30
  attr_accessor :score
@@ -177,6 +187,12 @@ module Fluent
177
187
 
178
188
  $log.debug "out_anomalydetect:#{Thread.current.object_id} flushed:#{flushed} val:#{val} outlier:#{outlier} outlier_buf:#{@outlier_buf} score:#{score}"
179
189
  if @threshold < 0 or (@threshold >= 0 and score > @threshold)
190
+ case @trend
191
+ when :up
192
+ return nil if val < @outlier.mu
193
+ when :down
194
+ return nil if val > @outlier.mu
195
+ end
180
196
  {"outlier" => outlier, "score" => score, "target" => val}
181
197
  else
182
198
  nil
@@ -246,4 +246,54 @@ class AnomalyDetectOutputTest < Test::Unit::TestCase
246
246
  end
247
247
  end
248
248
  end
249
+
250
+ def test_up_trend
251
+ d = create_driver %[
252
+ target y
253
+ trend up
254
+ ]
255
+
256
+ # should not output in down trend
257
+ d.run do
258
+ d.emit({'y' => 0.0}); d.instance.flush
259
+ d.emit({'y' => 0.0}); d.instance.flush
260
+ d.emit({'y' => 0.0}); d.instance.flush
261
+ d.emit({'y' => -1.0}); r = d.instance.flush
262
+ assert_equal nil, r
263
+ end
264
+
265
+ # should output in up trend
266
+ d.run do
267
+ d.emit({'y' => -1.0}); d.instance.flush
268
+ d.emit({'y' => -1.0}); d.instance.flush
269
+ d.emit({'y' => -1.0}); d.instance.flush
270
+ d.emit({'y' => 0.0}); r = d.instance.flush
271
+ assert_not_equal nil, r
272
+ end
273
+ end
274
+
275
+ def test_down_trend
276
+ d = create_driver %[
277
+ target y
278
+ trend down
279
+ ]
280
+ # should output in down trend
281
+ d.run do
282
+ d.emit({'y' => 0.0}); d.instance.flush
283
+ d.emit({'y' => 0.0}); d.instance.flush
284
+ d.emit({'y' => 0.0}); d.instance.flush
285
+ d.emit({'y' => -1.0}); r = d.instance.flush
286
+ assert_not_equal nil, r
287
+ end
288
+
289
+ # should not output in up tread
290
+ d.run do
291
+ d.emit({'y' => -1.0}); d.instance.flush
292
+ d.emit({'y' => -1.0}); d.instance.flush
293
+ d.emit({'y' => -1.0}); d.instance.flush
294
+ d.emit({'y' => 0.0})
295
+ r = d.instance.flush
296
+ assert_equal nil, r
297
+ end
298
+ end
249
299
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-anomalydetect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muddy Dixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.0.0
77
+ rubygems_version: 2.0.2
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: detect anomal sequential input casually