fluent-plugin-stats 0.3.5 → 0.3.6
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/.travis.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/fluent-plugin-stats.gemspec +1 -1
- data/lib/fluent/plugin/out_stats.rb +14 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b934f53568a8eee91bce6436279e8b6503057b
|
4
|
+
data.tar.gz: fea48bdcd8022fedee054ec732333a38eaa75714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94019310b7906f9638feef6d27614921c390298b4406df88663e95d70419ccd1fd5d2b75fc203989b835606f0d084e29e27fdf27fc8f0a0ccad32f10a705afd4
|
7
|
+
data.tar.gz: 9408530d2b650a126a19ca125883876da8f490be347073808f574b6b3d69126315325c0f6443439fe2cb3b3937d874b77511107266192d814882aaf61c99e9bd
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/fluent-plugin-stats.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-stats"
|
6
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.6"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-stats"
|
@@ -80,12 +80,14 @@ class Fluent::StatsOutput < Fluent::Output
|
|
80
80
|
matches = {}
|
81
81
|
prev_matches.keys.each do |aggregate_key|
|
82
82
|
next unless prev_matches[aggregate_key][:count] > 0 # Prohibit to emit anymore
|
83
|
-
matches[aggregate_key] = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
83
|
+
matches[aggregate_key] = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {}, :avg_count => {} }
|
84
84
|
# ToDo: would want default configuration for :max, :min
|
85
85
|
prev_matches[aggregate_key][:sum].keys.each {|key| matches[aggregate_key][:sum][key] = 0 }
|
86
86
|
prev_matches[aggregate_key][:max].keys.each {|key| matches[aggregate_key][:max][key] = 0 }
|
87
87
|
prev_matches[aggregate_key][:min].keys.each {|key| matches[aggregate_key][:min][key] = 0 }
|
88
88
|
prev_matches[aggregate_key][:avg].keys.each {|key| matches[aggregate_key][:avg][key] = 0 }
|
89
|
+
prev_matches[aggregate_key][:avg_count] ||= {} # for lower version compatibility
|
90
|
+
prev_matches[aggregate_key][:avg_count].keys.each {|key| matches[aggregate_key][:avg_count][key] = 0 }
|
89
91
|
end
|
90
92
|
matches
|
91
93
|
else
|
@@ -109,7 +111,7 @@ class Fluent::StatsOutput < Fluent::Output
|
|
109
111
|
# Called when new line comes. This method actually does not emit
|
110
112
|
def emit(tag, es, chain)
|
111
113
|
# stats
|
112
|
-
matches = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
114
|
+
matches = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {}, :avg_count => {} }
|
113
115
|
es.each do |time, record|
|
114
116
|
record = stringify_keys(record)
|
115
117
|
@sum_keys.each do |key|
|
@@ -127,6 +129,8 @@ class Fluent::StatsOutput < Fluent::Output
|
|
127
129
|
@avg_keys.each do |key|
|
128
130
|
next unless record[key] and value = record[key].to_f
|
129
131
|
matches[:avg][key] = sum(matches[:avg][key], value)
|
132
|
+
# ignore zero emitted value
|
133
|
+
matches[:avg_count][key] = sum(matches[:avg_count][key], 1) unless (@zero_emit and value.zero?)
|
130
134
|
end
|
131
135
|
record.keys.each do |key|
|
132
136
|
key = key.to_s
|
@@ -142,6 +146,8 @@ class Fluent::StatsOutput < Fluent::Output
|
|
142
146
|
end
|
143
147
|
if @avg and @avg.match(key)
|
144
148
|
matches[:avg][key] = sum(matches[:avg][key], value) # sum yet
|
149
|
+
# ignore zero emitted value
|
150
|
+
matches[:avg_count][key] = sum(matches[:avg_count][key], 1) unless (@zero_emit and value.zero?)
|
145
151
|
end
|
146
152
|
end if @sum || @max || @min || @avg
|
147
153
|
matches[:count] += 1
|
@@ -150,7 +156,8 @@ class Fluent::StatsOutput < Fluent::Output
|
|
150
156
|
aggregate_key = @aggregate_proc.call(tag)
|
151
157
|
|
152
158
|
# thread safe merge
|
153
|
-
@matches[aggregate_key] ||= { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
159
|
+
@matches[aggregate_key] ||= { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {}, :avg_count => {} }
|
160
|
+
@matches[aggregate_key][:avg_count] ||= {} # for lower version compatibility
|
154
161
|
@mutex.synchronize do
|
155
162
|
matches[:sum].keys.each do |key|
|
156
163
|
@matches[aggregate_key][:sum][key] = sum(@matches[aggregate_key][:sum][key], matches[:sum][key])
|
@@ -163,6 +170,7 @@ class Fluent::StatsOutput < Fluent::Output
|
|
163
170
|
end
|
164
171
|
matches[:avg].keys.each do |key|
|
165
172
|
@matches[aggregate_key][:avg][key] = sum(@matches[aggregate_key][:avg][key], matches[:avg][key]) # sum yet
|
173
|
+
@matches[aggregate_key][:avg_count][key] = sum(@matches[aggregate_key][:avg_count][key], matches[:avg_count][key])
|
166
174
|
end
|
167
175
|
@matches[aggregate_key][:count] += matches[:count]
|
168
176
|
end
|
@@ -230,9 +238,11 @@ class Fluent::StatsOutput < Fluent::Output
|
|
230
238
|
matches[:min].keys.each do |key|
|
231
239
|
output[key + @min_suffix] = matches[:min][key]
|
232
240
|
end
|
241
|
+
matches[:avg_count] ||= {} # for lower version compatibility
|
233
242
|
matches[:avg].keys.each do |key|
|
234
243
|
output[key + @avg_suffix] = matches[:avg][key]
|
235
|
-
|
244
|
+
count = matches[:avg_count][key].to_f
|
245
|
+
output[key + @avg_suffix] /= count unless count.zero?
|
236
246
|
end
|
237
247
|
output
|
238
248
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project: fluent-plugin-stats
|
138
|
-
rubygems_version: 2.2.
|
138
|
+
rubygems_version: 2.2.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Fluentd plugin to calculate statistics such as sum, max, min, avg
|