fluent-plugin-throttle 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +6 -2
- data/fluent-plugin-throttle.gemspec +1 -1
- data/lib/fluent/plugin/filter_throttle.rb +8 -9
- 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: 65759b9fff6dd920e4d1963a9d7ef7d786cd4708
|
4
|
+
data.tar.gz: fce8128e0943af6ce0dcb412658dcebdb426ea00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ac8f613190595a760cb2bdc44c7e1e270824c86ebcff96179751df63325798a2384eb8f4f4557455db6020698acf950de5f51b375be802177a504e6da671c1
|
7
|
+
data.tar.gz: fc74e2b98c362d0428ae9b24464a5466bec1ec17cef2827bf206ce707450f8700ffbb70453fc8b8c45338ded45879299695ec795404a4d6a9405000f2662299b
|
data/README.md
CHANGED
@@ -15,8 +15,12 @@ $ gem install fluent-plugin-throttle
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
```xml
|
18
|
-
<filter
|
19
|
-
|
18
|
+
<filter **>
|
19
|
+
@type throttle
|
20
|
+
group_key kubernetes.container_name
|
21
|
+
group_bucket_period_s 60
|
22
|
+
group_bucket_limit 6000
|
23
|
+
group_reset_rate_s 100
|
20
24
|
</filter>
|
21
25
|
```
|
22
26
|
|
@@ -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-throttle"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["François-Xavier Bourlet"]
|
9
9
|
spec.email = ["fx.bourlet@rubrik.com"]
|
10
10
|
spec.summary = %q{Fluentd filter for throttling logs based on a configurable key.}
|
@@ -14,7 +14,7 @@ module Fluent
|
|
14
14
|
Group = Struct.new(
|
15
15
|
:rate_count,
|
16
16
|
:rate_last_reset,
|
17
|
-
:
|
17
|
+
:aprox_rate,
|
18
18
|
:bucket_count,
|
19
19
|
:bucket_last_reset,
|
20
20
|
:last_warning)
|
@@ -66,7 +66,7 @@ module Fluent
|
|
66
66
|
since_last_rate_reset = now - counter.rate_last_reset
|
67
67
|
if since_last_rate_reset >= 1
|
68
68
|
# compute and store rate/s at most every seconds.
|
69
|
-
counter.
|
69
|
+
counter.aprox_rate = (counter.rate_count / since_last_rate_reset).round()
|
70
70
|
counter.rate_count = 0
|
71
71
|
counter.rate_last_reset = now
|
72
72
|
end
|
@@ -77,11 +77,11 @@ module Fluent
|
|
77
77
|
|
78
78
|
if counter.bucket_count == -1 and @group_reset_rate_s != -1
|
79
79
|
# wait until rate drops back down if needed.
|
80
|
-
if counter.
|
80
|
+
if counter.aprox_rate < @group_reset_rate_s
|
81
81
|
log_rate_back_down(now, group, counter)
|
82
82
|
else
|
83
83
|
since_last_warning = now - counter.last_warning
|
84
|
-
if since_last_warning
|
84
|
+
if since_last_warning >= @warning_delay
|
85
85
|
log_rate_limit_exceeded(now, group, counter)
|
86
86
|
counter.last_warning = now
|
87
87
|
end
|
@@ -122,11 +122,10 @@ module Fluent
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def log_items(now, group, counter)
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
125
|
+
since_last_reset = now - counter.bucket_last_reset
|
126
|
+
rate = (counter.bucket_count / since_last_reset).round()
|
127
|
+
aprox_rate = counter.aprox_rate
|
128
|
+
rate = aprox_rate if aprox_rate > rate
|
130
129
|
|
131
130
|
{'group_key': group,
|
132
131
|
'rate_s': rate,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François-Xavier Bourlet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|