fluent-plugin-threshold 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -3
- data/lib/fluent/plugin/out_threshold.rb +15 -7
- data/lib/fluent/plugin/threshold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5540c3da3af346b1167fba05190ae2dac86a065
|
4
|
+
data.tar.gz: 03c4ea64348dd61c70686ab9570d8a88602f66dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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 :
|
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 @
|
36
|
-
raise ConfigError, "fluent-plugin-threshold: '
|
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 @
|
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
|
96
|
+
raise ArgumentError.new("no such operator: #{@operator}")
|
89
97
|
end
|
90
98
|
|
91
99
|
filter_record
|
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.
|
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-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|