fluent-plugin-calc 0.0.2 → 0.0.3

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: a1c071f135ee347fbda42cabebcf97145738e861
4
- data.tar.gz: d96f235f6f89144c8c576be0a8502034355c6147
3
+ metadata.gz: c1a0fa5a4f57cb4b44e75759fdf27f0db87fe498
4
+ data.tar.gz: 994beab4aca4623426effc9fbd6d1d0e8dfcaf91
5
5
  SHA512:
6
- metadata.gz: 10600118061e558c871707bff0c6d24c55aa2c6b3dea62c176a5ac0f2e317dc2d1dd116bf306c2f4a806e26510105a2b6ce5d4969b4ff349e1152b4e885a4019
7
- data.tar.gz: 2ddf8699037167a5bd72aef1a3489d73487bbb75c1befd80c77cf2be0d60e3c70468eb45fbdba1efa6f52417926c69bd45bd117b1881eb48b610edd3af5aec7f
6
+ metadata.gz: e1a71b149904a8a9768d32ca86a1f632f2f31dad02a95bc421323db9807b014e10abe3f7c47bbec675982fcebc3db386131286f10b182af6406ad7baf4858e8a
7
+ data.tar.gz: b8b9562c574be42c7e984b4d7c67ad9064a8009984389890d4d336cfe95fa803882c2d461ea74bcebd5b25e9e35eb5eb39368e863cb2aca9d77a6192376bde7f
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # fluent-plugin-calc [![Build Status](https://secure.travis-ci.org/sonots/fluent-plugin-calc.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-calc) [![Dependency Status](https://gemnasium.com/sonots/fluent-plugin-calc.png)](https://gemnasium.com/sonots/fluent-plugin-calc) [![Coverage Status](https://coveralls.io/repos/sonots/fluent-plugin-calc/badge.png?branch=master)](https://coveralls.io/r/sonots/fluent-plugin-calc)
2
2
 
3
- Fluentd plugin to calc messages.
3
+ Simple fluentd plugin to calculate messages.
4
4
 
5
5
  ## Configuration
6
6
 
7
+ Example (sum for xxx_count, max for xxx_max, min for xxx_min, avg for xxx_avg):
8
+
7
9
  <match foo.**>
8
10
  type calc
9
11
  interval 5s
@@ -20,7 +22,7 @@ Assuming following inputs are coming:
20
22
  foo.bar: {"4xx_count":1,"5xx_count":2","reqtime_max":12083,"reqtime_min":10,"reqtime_avg":240.46}
21
23
  foo.bar: {"4xx_count":4,"5xx_count":2","reqtime_max":24831,"reqtime_min":82,"reqtime_avg":300.46}
22
24
 
23
- then output bocomes as belows:
25
+ then output bocomes as belows:
24
26
 
25
27
  calc.foo.bar: {"4xx_count":5,"5xx_count":4","reqtime_max":24831,"reqtime_min":82,"reqtime_avg":270.46}
26
28
 
@@ -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-calc"
6
- s.version = "0.0.2"
6
+ s.version = "0.0.3"
7
7
  s.authors = ["Naotoshi SEO"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-calc"
@@ -88,6 +88,8 @@ class Fluent::CalcOutput < Fluent::Output
88
88
  end
89
89
 
90
90
  chain.next
91
+ rescue => e
92
+ $log.warn "#{e.class} #{e.message} #{e.backtrace.first}"
91
93
  end
92
94
 
93
95
  # thread callback
@@ -96,10 +98,14 @@ class Fluent::CalcOutput < Fluent::Output
96
98
  @last_checked = Fluent::Engine.now
97
99
  while true
98
100
  sleep 0.5
99
- if Fluent::Engine.now - @last_checked >= @interval
100
- now = Fluent::Engine.now
101
- flush_emit(now - @last_checked)
102
- @last_checked = now
101
+ begin
102
+ if Fluent::Engine.now - @last_checked >= @interval
103
+ now = Fluent::Engine.now
104
+ flush_emit(now - @last_checked)
105
+ @last_checked = now
106
+ end
107
+ rescue => e
108
+ $log.warn "#{e.class} #{e.message} #{e.backtrace.first}"
103
109
  end
104
110
  end
105
111
  end
@@ -119,6 +125,7 @@ class Fluent::CalcOutput < Fluent::Output
119
125
  end
120
126
 
121
127
  def generate_output(count, matches)
128
+ return nil if matches.empty?
122
129
  output = matches.dup
123
130
  output.keys.each do |key|
124
131
  if @avg and @avg.match(key)
@@ -69,7 +69,6 @@ describe Fluent::CalcOutput do
69
69
  let(:messages) do
70
70
  [
71
71
  {"4xx_count"=>1,"5xx_count"=>2,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3},
72
- {">4sec_count"=>1},
73
72
  {"4xx_count"=>2,"5xx_count"=>2,"reqtime_max"=>5,"reqtime_min"=>2,"reqtime_avg"=>2},
74
73
  {"4xx_count"=>3,"5xx_count"=>2,"reqtime_max"=>1,"reqtime_min"=>3,"reqtime_avg"=>4},
75
74
  ]
@@ -140,6 +139,9 @@ describe Fluent::CalcOutput do
140
139
  aggregate all
141
140
  tag foo
142
141
  sum _count$
142
+ max _max$
143
+ min _min$
144
+ avg _avg$
143
145
  ]
144
146
  end
145
147
  before do
@@ -157,6 +159,9 @@ describe Fluent::CalcOutput do
157
159
  aggregate tag
158
160
  add_tag_prefix calc
159
161
  sum _count$
162
+ max _max$
163
+ min _min$
164
+ avg _avg$
160
165
  ]
161
166
  end
162
167
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi SEO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-06 00:00:00.000000000 Z
11
+ date: 2013-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project: fluent-plugin-calc
123
- rubygems_version: 2.0.0
123
+ rubygems_version: 2.0.2
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: fluentd plugin to calc messages