fluent-plugin-cloudwatch 1.2.5 → 1.2.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.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+
7
+ gemfile:
8
+ - Gemfile
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # fluent-plugin-cloudwatch
1
+ # fluent-plugin-cloudwatch [![Build Status](https://travis-ci.org/yunomu/fluent-plugin-cloudwatch.png)](https://travis-ci.org/yunomu/fluent-plugin-cloudwatch/)
2
2
 
3
3
 
4
4
  ## Overview
@@ -189,6 +189,29 @@ Note: Billing requires the us-east-1 endpoint
189
189
 
190
190
  ```
191
191
 
192
+ ### GET StorageGateway Metirc
193
+
194
+ ```config
195
+ type cloudwatch
196
+ tag cloudwatch
197
+ aws_key_id YOUR_AWS_KEY_ID
198
+ aws_sec_key YOUR_AWS_SECRET/KE
199
+ cw_endpoint monitoring.us-east-1.amazonaws.com
200
+
201
+ namespace AWS/StorageGateway
202
+ metric_name CacheHitPercent,CachePercentUsed
203
+ dimensions_name GatewayId,GatewayName
204
+ dimensions_value sgw-XXXXXXXX,mygateway
205
+ statistics Average
206
+ ```
207
+
208
+ #### output data format
209
+
210
+ ```
211
+ 2014-01-20 20:12:00 +0900 cloudwatch: {"CacheHitPercent":0.0}
212
+ 2014-01-20 20:12:00 +0900 cloudwatch: {"CachePercentUsed":95.15519175634687}
213
+ ```
214
+
192
215
  ## Contributing
193
216
 
194
217
  1. Fork it
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-cloudwatch"
7
- gem.version = "1.2.5"
7
+ gem.version = "1.2.6"
8
8
  gem.authors = ["Yusuke Nomura", "kenjiskywalker"]
9
9
  gem.email = ["yunomu@gmail.com", "git@kenjiskywalker.org"]
10
10
  gem.description = %q{Input plugin for AWS CloudWatch.}
@@ -16,5 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.add_dependency "fluentd", "~> 0.10.30"
18
18
  gem.add_dependency "aws-sdk", "= 1.8.3"
19
+ gem.add_development_dependency "rake", ">= 0.9.2"
19
20
  gem.license = 'MIT'
20
21
  end
@@ -1,6 +1,11 @@
1
1
  class Fluent::CloudwatchInput < Fluent::Input
2
2
  Fluent::Plugin.register_input("cloudwatch", self)
3
3
 
4
+ # To support log_level option implemented by Fluentd v0.10.43
5
+ unless method_defined?(:log)
6
+ define_method("log") { $log }
7
+ end
8
+
4
9
  config_param :tag, :string
5
10
  config_param :aws_key_id, :string, :default => nil
6
11
  config_param :aws_sec_key, :string, :default => nil
@@ -16,8 +21,9 @@ class Fluent::CloudwatchInput < Fluent::Input
16
21
  config_param :open_timeout, :integer, :default => 10
17
22
  config_param :read_timeout, :integer, :default => 30
18
23
 
24
+ attr_accessor :dimensions
19
25
 
20
- def initialize
26
+ def initialize
21
27
  super
22
28
  require 'aws-sdk'
23
29
  end
@@ -25,6 +31,23 @@ class Fluent::CloudwatchInput < Fluent::Input
25
31
  def configure(conf)
26
32
  super
27
33
 
34
+ @dimensions = []
35
+ if @dimensions_name && @dimensions_value
36
+ names = @dimensions_name.split(",").each
37
+ values = @dimensions_value.split(",").each
38
+ loop do
39
+ @dimensions.push({
40
+ :name => names.next,
41
+ :value => values.next,
42
+ })
43
+ end
44
+ else
45
+ @dimensions.push({
46
+ :name => @dimensions_name,
47
+ :value => @dimensions_value,
48
+ })
49
+ end
50
+
28
51
  AWS.config(
29
52
  :http_open_timeout => @open_timeout,
30
53
  :http_read_timeout => @read_timeout,
@@ -62,10 +85,7 @@ class Fluent::CloudwatchInput < Fluent::Input
62
85
  :namespace => @namespace,
63
86
  :metric_name => m,
64
87
  :statistics => [@statistics],
65
- :dimensions => [{
66
- :name => @dimensions_name,
67
- :value => @dimensions_value,
68
- }],
88
+ :dimensions => @dimensions,
69
89
  :start_time => (Time.now - @period*2).iso8601,
70
90
  :end_time => Time.now.iso8601,
71
91
  :period => @period,
@@ -81,6 +101,8 @@ class Fluent::CloudwatchInput < Fluent::Input
81
101
  # no output_data.to_json
82
102
  output_data = {m => data}
83
103
  Fluent::Engine.emit(tag, catch_time, output_data)
104
+ else
105
+ log.warn "cloudwatch: statistics[:datapoints] is empty"
84
106
  end
85
107
  }
86
108
  sleep 1
@@ -31,6 +31,7 @@ class CloudwatchInputTest < Test::Unit::TestCase
31
31
  assert_equal 'CPUUtilization,FreeStorageSpace,DiskQueueDepth,FreeableMemory,SwapUsage,ReadIOPS,ReadLatency,ReadThroughput,WriteIOPS,WriteLatency,WriteThroughput', d.instance.metric_name
32
32
  assert_equal 'DBInstanceIdentifier', d.instance.dimensions_name
33
33
  assert_equal 'rds01', d.instance.dimensions_value
34
+ assert_equal [{ :name => 'DBInstanceIdentifier', :value => 'rds01' }], d.instance.dimensions
34
35
  end
35
36
 
36
37
 
@@ -60,6 +61,36 @@ class CloudwatchInputTest < Test::Unit::TestCase
60
61
  assert_equal 'CPUUtilization,FreeStorageSpace,DiskQueueDepth,FreeableMemory,SwapUsage,ReadIOPS,ReadLatency,ReadThroughput,WriteIOPS,WriteLatency,WriteThroughput', d.instance.metric_name
61
62
  assert_equal 'InstanceId', d.instance.dimensions_name
62
63
  assert_equal 'ec2-01', d.instance.dimensions_value
64
+ assert_equal [{ :name => 'InstanceId', :value => 'ec2-01' }], d.instance.dimensions
65
+ end
66
+
67
+ ### for StorageGateway
68
+ CONFIG_SG = %[
69
+ tag cloudwatch
70
+ aws_key_id test_key_id
71
+ aws_sec_key test_sec_key
72
+ cw_endpoint test_cloud_watch_endpoint
73
+ namespace AWS/StorageGateway
74
+ metric_name CacheHitPercent,CachePercentUsed
75
+ dimensions_name GatewayId,GatewayName
76
+ dimensions_value sgw-XXXXXXXX,mygateway
77
+ ]
78
+
79
+ def create_driver_sg(conf = CONFIG_SG)
80
+ Fluent::Test::InputTestDriver.new(Fluent::CloudwatchInput).configure(conf)
81
+ end
82
+
83
+ def test_configure_sg
84
+ d = create_driver_sg
85
+ assert_equal 'cloudwatch', d.instance.tag
86
+ assert_equal 'test_key_id', d.instance.aws_key_id
87
+ assert_equal 'test_sec_key', d.instance.aws_sec_key
88
+ assert_equal 'test_cloud_watch_endpoint', d.instance.cw_endpoint
89
+ assert_equal 'AWS/StorageGateway', d.instance.namespace
90
+ assert_equal 'CacheHitPercent,CachePercentUsed', d.instance.metric_name
91
+ assert_equal 'GatewayId,GatewayName', d.instance.dimensions_name
92
+ assert_equal 'sgw-XXXXXXXX,mygateway', d.instance.dimensions_value
93
+ assert_equal [{ :name => "GatewayId", :value => "sgw-XXXXXXXX" }, { :name => "GatewayName", :value => "mygateway" }], d.instance.dimensions
63
94
  end
64
95
 
65
96
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cloudwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Yusuke Nomura
@@ -9,11 +10,12 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-10-03 00:00:00.000000000 Z
13
+ date: 2014-02-05 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: fluentd
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ~>
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ~>
26
29
  - !ruby/object:Gem::Version
@@ -28,6 +31,7 @@ dependencies:
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: aws-sdk
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
36
  - - '='
33
37
  - !ruby/object:Gem::Version
@@ -35,10 +39,27 @@ dependencies:
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
44
  - - '='
40
45
  - !ruby/object:Gem::Version
41
46
  version: 1.8.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.9.2
42
63
  description: Input plugin for AWS CloudWatch.
43
64
  email:
44
65
  - yunomu@gmail.com
@@ -48,6 +69,7 @@ extensions: []
48
69
  extra_rdoc_files: []
49
70
  files:
50
71
  - .gitignore
72
+ - .travis.yml
51
73
  - Gemfile
52
74
  - LICENSE
53
75
  - README.md
@@ -59,26 +81,27 @@ files:
59
81
  homepage: https://github.com/yunomu/fluent-plugin-cloudwatch
60
82
  licenses:
61
83
  - MIT
62
- metadata: {}
63
84
  post_install_message:
64
85
  rdoc_options: []
65
86
  require_paths:
66
87
  - lib
67
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
68
90
  requirements:
69
- - - '>='
91
+ - - ! '>='
70
92
  - !ruby/object:Gem::Version
71
93
  version: '0'
72
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
73
96
  requirements:
74
- - - '>='
97
+ - - ! '>='
75
98
  - !ruby/object:Gem::Version
76
99
  version: '0'
77
100
  requirements: []
78
101
  rubyforge_project:
79
- rubygems_version: 2.0.3
102
+ rubygems_version: 1.8.23
80
103
  signing_key:
81
- specification_version: 4
104
+ specification_version: 3
82
105
  summary: Input plugin for AWS CloudWatch.
83
106
  test_files:
84
107
  - test/helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1d74deec9a580641e39759288103927bc8d192c7
4
- data.tar.gz: 6eacd7162f2c882460b903a9ca54694baab6703c
5
- SHA512:
6
- metadata.gz: 5b05469fd665b61b9d76eacc4e2860cfe4e2750a87cc690c4e9e59f681f09951f232b2d4bd0d25456caa484d50866ae881896dcf7400cd83314f5b3d60e683b6
7
- data.tar.gz: 9b794b419cafc4630788248071b18db8d1097b0cee9429e472aa32a6d1272114f83da990d7cd10f262624a6c180912d547a38f630aa75c54099793a32c839931