fluent-plugin-threshold 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db9e91133907aab98d70c390290b03e9d1898232
4
- data.tar.gz: d8bc2ac9a0db0006e3564302adb7e48ea1b1e1ec
3
+ metadata.gz: e5540c3da3af346b1167fba05190ae2dac86a065
4
+ data.tar.gz: 03c4ea64348dd61c70686ab9570d8a88602f66dd
5
5
  SHA512:
6
- metadata.gz: f222aea881afd23b1d6fe469a4722684b991143b9295ffd7986ab99acd8e1fc13be771cc399ff6c7e831385e0f83416fee7fb53eefe20b3261a75ef9119c7788
7
- data.tar.gz: 894c4801adeae51d73fc46f10500295bd779484770a5ae9b9a80a42398786102a38ea67119db19c0ae2a69a4e97decbac2bb299a797fbd72610695d3f5de4d36
6
+ metadata.gz: 75d3666c14ee14fad569c7a51132e1528ccd4a7d143c48f1c2236d8a32dfe3511d3a1db16e762ccb14bce3b2b37059779197c6a37ea4b4d314d3cb0e434c64f9
7
+ data.tar.gz: ae72e9f23e12502740a2375b319c6d807fd3efc9350d7f9bf29677574ec570050d178f0bac4befcc0123919c848f8d1caa512890101b4147229aea78d5a9f53e
data/README.md CHANGED
@@ -19,18 +19,26 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
- configuration:
22
+ config_params (all required):
23
+
24
+ name | values
25
+ -------------------------------- | ------------------------------------------
26
+ operator | ge, gt, le, lt, string, regexp.
27
+ threshold | string, integer, and float value.
28
+ target_key | json property name.
29
+ {add|remove}_tag_{prefix|suffix} | string
30
+
31
+ configuration example:
23
32
  ```xml
24
33
  <match th>
25
34
  type threshold
26
- condition ge
35
+ operator ge
27
36
  threshold 15
28
37
  target_key count
29
38
  add_tag_prefix th.
30
39
  </match>
31
40
  ```
32
41
 
33
-
34
42
  input JSON:
35
43
  ```json
36
44
  {"user_id": "123", "count": 11, "uri": "/*"}
@@ -5,7 +5,7 @@ module Fluent
5
5
 
6
6
  Fluent::Plugin.register_output('threshold', self)
7
7
 
8
- config_param :condition, :string
8
+ config_param :operator, :string
9
9
  config_param :threshold, :string
10
10
  config_param :target_key, :string
11
11
 
@@ -14,8 +14,8 @@ module Fluent
14
14
  end
15
15
 
16
16
  # <match *>
17
- # condition eq | ne | gl | ge | lt | le
18
- # threshold <float> | <integer>
17
+ # condition eq | ne | gl | ge | lt | le | string | regexp
18
+ # threshold <float> | <integer> | <string> | <regexp>
19
19
  # target_key <key_name>
20
20
  # </match>
21
21
  def initialize
@@ -32,8 +32,8 @@ module Fluent
32
32
  end
33
33
 
34
34
  # You can also refer raw parameter via conf[name].
35
- unless @condition
36
- raise ConfigError, "fluent-plugin-threshold: 'filter' parameter is required"
35
+ unless @operator
36
+ raise ConfigError, "fluent-plugin-threshold: 'operator' parameter is required"
37
37
  end
38
38
 
39
39
  unless @threshold
@@ -59,7 +59,7 @@ module Fluent
59
59
  super
60
60
 
61
61
  filter_record = {}
62
- case @condition
62
+ case @operator
63
63
  when "eq"
64
64
  if record.member?(@target_key) && record[@target_key].to_f == threshold.to_f
65
65
  filter_record = record
@@ -84,8 +84,16 @@ module Fluent
84
84
  if record.member?(@target_key) && record[@target_key].to_f < threshold.to_f
85
85
  filter_record = record
86
86
  end
87
+ when "string"
88
+ if record.member?(@target_key) && record[@target_key].eql?(threshold)
89
+ filter_record = record
90
+ end
91
+ when "regexp"
92
+ if record.member?(@target_key) && /#{threshold}/ =~ record[@target_key]
93
+ filter_record = record
94
+ end
87
95
  else
88
- raise ArgumentError.new("no such condition: #{@condition}")
96
+ raise ArgumentError.new("no such operator: #{@operator}")
89
97
  end
90
98
 
91
99
  filter_record
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module Threshold
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-threshold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - moulin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd