fluent-plugin-growthforecast 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{fluent-plugin-growthforecast}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{TAGOMORI Satoshi}]
12
+ s.date = %q{2012-03-01}
13
+ s.description = %q{Plugin to post numbers to GrowthForecast (by kazeburo)}
14
+ s.email = %q{tagomoris@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "AUTHORS",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "fluent-plugin-growthforecast.gemspec",
29
+ "lib/fluent/plugin/out_growthforecast.rb",
30
+ "test/helper.rb",
31
+ "test/plugin/test_out_growthforecast.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/tagomoris/fluent-plugin-growthforecast}
34
+ s.require_paths = [%q{lib}]
35
+ s.rubygems_version = %q{1.8.6}
36
+ s.summary = %q{Plugin to post numbers to GrowthForecast (by kazeburo)}
37
+ s.test_files = [%q{test/helper.rb}, %q{test/plugin/test_out_growthforecast.rb}]
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<fluentd>, [">= 0"])
44
+ s.add_runtime_dependency(%q<rdoc>, [">= 0"])
45
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
48
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
49
+ s.add_runtime_dependency(%q<fluentd>, ["~> 0.10.8"])
50
+ s.add_development_dependency(%q<rake>, [">= 0.9.2"])
51
+ s.add_development_dependency(%q<simplecov>, [">= 0.5.4"])
52
+ else
53
+ s.add_dependency(%q<fluentd>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, [">= 0"])
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
58
+ s.add_dependency(%q<simplecov>, [">= 0"])
59
+ s.add_dependency(%q<fluentd>, ["~> 0.10.8"])
60
+ s.add_dependency(%q<rake>, [">= 0.9.2"])
61
+ s.add_dependency(%q<simplecov>, [">= 0.5.4"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<fluentd>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, [">= 0"])
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
69
+ s.add_dependency(%q<simplecov>, [">= 0"])
70
+ s.add_dependency(%q<fluentd>, ["~> 0.10.8"])
71
+ s.add_dependency(%q<rake>, [">= 0.9.2"])
72
+ s.add_dependency(%q<simplecov>, [">= 0.5.4"])
73
+ end
74
+ end
75
+
@@ -10,7 +10,9 @@ class Fluent::GrowthForecastOutput < Fluent::Output
10
10
  config_param :gfapi_url, :string # growth.forecast.local/api/
11
11
  config_param :service, :string
12
12
  config_param :section, :string, :default => nil
13
- config_param :name_keys, :string
13
+
14
+ config_param :name_keys, :string, :default => nil
15
+ config_param :name_key_pattern, :string, :default => nil
14
16
 
15
17
  config_param :mode, :string, :default => 'gauge' # or count/modified
16
18
 
@@ -25,6 +27,19 @@ class Fluent::GrowthForecastOutput < Fluent::Output
25
27
  end
26
28
  @gfurl = @gfapi_url + @service + '/'
27
29
 
30
+ if @name_keys.nil? and @name_key_pattern.nil?
31
+ raise Fluent::ConfigError, "missing both of name_keys and name_key_pattern"
32
+ end
33
+ if not @name_keys.nil? and not @name_key_pattern.nil?
34
+ raise Fluent::ConfigError, "cannot specify both of name_keys and name_key_pattern"
35
+ end
36
+ if @name_keys
37
+ @name_keys = @name_keys.split(',')
38
+ end
39
+ if @name_key_pattern
40
+ @name_key_pattern = Regexp.new(@name_key_pattern)
41
+ end
42
+
28
43
  @mode = case @mode
29
44
  when 'count' then :count
30
45
  when 'modified' then :modified
@@ -45,7 +60,6 @@ class Fluent::GrowthForecastOutput < Fluent::Output
45
60
  @removed_prefix_string = @remove_prefix + '.'
46
61
  @removed_length = @removed_prefix_string.length
47
62
  end
48
- @name_keys = @name_keys.split(',')
49
63
  end
50
64
 
51
65
  def start
@@ -69,11 +83,14 @@ class Fluent::GrowthForecastOutput < Fluent::Output
69
83
 
70
84
  def post(tag, name, value)
71
85
  url = format_url(tag,name)
72
- res = Net::HTTP.post_form(URI.parse(url), {'number' => value.to_i, 'mode' => @mode.to_s})
73
- case res
74
- when Net::HTTPSuccess
75
- # OK
76
- else
86
+ begin
87
+ res = Net::HTTP.post_form(URI.parse(url), {'number' => value.to_i, 'mode' => @mode.to_s})
88
+ rescue IOError, EOFError, SystemCallError
89
+ # server didn't respond
90
+ $log.warn "Net::HTTP.post_form raises exception: #{$!.class}, '#{$!.message}'"
91
+ res = nil
92
+ end
93
+ unless res and res.is_a?(Net::HTTPSuccess)
77
94
  $log.warn "failed to post to growthforecast: #{url}, number: #{value}, code: #{res.code}"
78
95
  end
79
96
  end
@@ -83,13 +100,23 @@ class Fluent::GrowthForecastOutput < Fluent::Output
83
100
  ( (tag.start_with?(@removed_prefix_string) and tag.length > @removed_length) or tag == @remove_prefix)
84
101
  tag = tag[@removed_length..-1]
85
102
  end
86
- es.each {|time,record|
87
- @name_keys.each {|name|
88
- if record[name]
89
- post(tag, name, record[name])
90
- end
103
+ if @name_keys
104
+ es.each {|time,record|
105
+ @name_keys.each {|name|
106
+ if record[name]
107
+ post(tag, name, record[name])
108
+ end
109
+ }
91
110
  }
92
- }
111
+ else # for name_key_pattern
112
+ es.each {|time,record|
113
+ record.keys.each {|key|
114
+ if @name_key_pattern.match(key) and record[key]
115
+ post(tag, key, record[key])
116
+ end
117
+ }
118
+ }
119
+ end
93
120
  chain.next
94
121
  end
95
122
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-growthforecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-18 00:00:00.000000000Z
12
+ date: 2012-03-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
- requirement: &2160082200 !ruby/object:Gem::Requirement
16
+ requirement: &2151940280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2160082200
24
+ version_requirements: *2151940280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &2160081720 !ruby/object:Gem::Requirement
27
+ requirement: &2151939800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2160081720
35
+ version_requirements: *2151939800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &2160081240 !ruby/object:Gem::Requirement
38
+ requirement: &2151939320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2160081240
46
+ version_requirements: *2151939320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &2160080760 !ruby/object:Gem::Requirement
49
+ requirement: &2151938840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2160080760
57
+ version_requirements: *2151938840
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &2160080280 !ruby/object:Gem::Requirement
60
+ requirement: &2151938360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.6.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2160080280
68
+ version_requirements: *2151938360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &2160079800 !ruby/object:Gem::Requirement
71
+ requirement: &2151937880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2160079800
79
+ version_requirements: *2151937880
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fluentd
82
- requirement: &2160079320 !ruby/object:Gem::Requirement
82
+ requirement: &2151937400 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.10.8
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *2160079320
90
+ version_requirements: *2151937400
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &2160078840 !ruby/object:Gem::Requirement
93
+ requirement: &2151936920 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.9.2
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2160078840
101
+ version_requirements: *2151936920
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &2160078360 !ruby/object:Gem::Requirement
104
+ requirement: &2151936440 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 0.5.4
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2160078360
112
+ version_requirements: *2151936440
113
113
  description: Plugin to post numbers to GrowthForecast (by kazeburo)
114
114
  email: tagomoris@gmail.com
115
115
  executables: []
@@ -126,6 +126,7 @@ files:
126
126
  - README.rdoc
127
127
  - Rakefile
128
128
  - VERSION
129
+ - fluent-plugin-growthforecast.gemspec
129
130
  - lib/fluent/plugin/out_growthforecast.rb
130
131
  - test/helper.rb
131
132
  - test/plugin/test_out_growthforecast.rb
@@ -143,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  segments:
145
146
  - 0
146
- hash: -1863730412705014917
147
+ hash: 1766980505179376009
147
148
  required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  none: false
149
150
  requirements: