fluent-plugin-cloudwatch 1.2.7 → 1.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36e2969f74749ad54025253cb94f0528c5bc7ccf
4
- data.tar.gz: 5f02e13c932e3b458790b0a589f64ccd04c23f64
3
+ metadata.gz: 676e50628ee8eaed446c8ce90ee2415b4590c58e
4
+ data.tar.gz: b5d61bd882a2d9391552f56840c3d723efc76c7a
5
5
  SHA512:
6
- metadata.gz: 4535f7688efc8f45afc0f4215c256e701f06be7bffc092c64a0fbfbfe8455ee88e96d591639ace1cf194fa33438c0775cd51aced2f7f129f7b9f4b4ec3a23cc1
7
- data.tar.gz: 042774d37dbf1f3c7410e924b91a876fc5e65fec5108c500dfec669105d9b1a706622a9d09e36656760a44f36020d0bb906e971589d448123c67479c096b7efb
6
+ metadata.gz: 49aee0b5ad1da7a0f30b440d0faf37f4a861305469efd89757b20cc26bdbab1485716376cc4228d443817fe14d5d0e37653ed13e7944a65e4aae66c198abca55
7
+ data.tar.gz: 393eb9f72736d129b3edd8967a4dce328b95df8c9d31fd8e0feea57dc199c06f66b899295ecb84a7f845d49a745672f876c9499fda524fa0083ff6fce9d9dcde
data/README.md CHANGED
@@ -2,13 +2,15 @@
2
2
 
3
3
 
4
4
  ## Overview
5
- ***AWS CloudWatch*** input plugin.
6
5
 
7
- this plugin is simple.
8
- get metrics from cloudwatch.
6
+ ***AWS CloudWatch*** input plugin.
9
7
 
10
- 1. get every 300 seconds from AWS CloudWatch API(sleep 1sec)
11
- 2. 300 seconds of data
8
+ This plugin is simple.
9
+ Get metrics from cloudwatch to fluentd.
10
+
11
+ * Get metrics from AWS CloudWatch API.
12
+ * Interval is 300(default. config=interval) seconds
13
+ * Fetch datapoints in recent (interval * 10) seconds, and emit the latest datapoint to Fluentd data stream.
12
14
 
13
15
  ## Configuration
14
16
 
@@ -27,8 +29,8 @@ get metrics from cloudwatch.
27
29
  dimensions_value [dimensions value]
28
30
  period [period] (default: 300)
29
31
  interval [interval] (default: 300)
32
+ delayed_start [bool] (default: false)
30
33
  </source>
31
-
32
34
  ```
33
35
 
34
36
  ### GET RDS Metric
@@ -94,13 +96,11 @@ get metrics from cloudwatch.
94
96
  #### output data format
95
97
 
96
98
  ```
97
-
98
99
  2013-03-21T14:08:00+09:00 cloudwatch {"HealthyHostCount":2.0}
99
100
  2013-03-21T14:08:00+09:00 cloudwatch {"HTTPCode_Backend_2XX":1.0}
100
101
  2013-03-21T14:08:00+09:00 cloudwatch {"Latency":0.004025}
101
102
  2013-03-21T14:08:00+09:00 cloudwatch {"RequestCount":1.0}
102
103
  2013-03-21T14:09:00+09:00 cloudwatch {"UnHealthyHostCount":0.0}
103
-
104
104
  ```
105
105
 
106
106
 
@@ -124,7 +124,6 @@ get metrics from cloudwatch.
124
124
  #### output data format
125
125
 
126
126
  ```
127
-
128
127
  2013-02-25T00:44:00+09:00 cloudwatch {"CPUUtilization":1.58}
129
128
  2013-02-25T00:44:00+09:00 cloudwatch {"DiskReadBytes":0.0}
130
129
  2013-02-25T00:44:00+09:00 cloudwatch {"DiskReadBytes":0.0}
@@ -132,7 +131,6 @@ get metrics from cloudwatch.
132
131
  2013-02-25T00:44:00+09:00 cloudwatch {"DiskWriteOps":0.0}
133
132
  2013-02-25T00:44:00+09:00 cloudwatch {"NetworkIn":95183.0}
134
133
  2013-02-25T00:44:00+09:00 cloudwatch {"NetworkOut":95645.0}
135
-
136
134
  ```
137
135
 
138
136
  ### GET DynamoDB Metirc
@@ -156,10 +154,8 @@ get metrics from cloudwatch.
156
154
  #### output data format
157
155
 
158
156
  ```
159
-
160
157
  2013-04-11 15:13:00 +0900 cloudwatch {"ConsumedReadCapacityUnits":8271.5}
161
158
  2013-04-11 15:13:00 +0900 cloudwatch {"ConsumedWriteCapacityUnits":2765.5}
162
-
163
159
  ```
164
160
 
165
161
  ### GET Billing Metirc
@@ -183,10 +179,8 @@ Note: Billing requires the us-east-1 endpoint
183
179
  #### output data format
184
180
 
185
181
  ```
186
-
187
182
  2013-06-10 02:03:00 +0900 cloudwatch {"EstimatedCharges_in_USD":"543.175"}
188
183
  2013-06-10 04:03:00 +0900 cloudwatch {"EstimatedCharges_in_USD":"550.39"}
189
-
190
184
  ```
191
185
 
192
186
  ### GET StorageGateway Metirc
@@ -212,6 +206,11 @@ Note: Billing requires the us-east-1 endpoint
212
206
  2014-01-20 20:12:00 +0900 cloudwatch: {"CachePercentUsed":95.15519175634687}
213
207
  ```
214
208
 
209
+
210
+ ## config: delayed_start
211
+
212
+ When config `delayed_start` is set true, plugin startup will be delayed in random seconds(0 ~ interval).
213
+
215
214
  ## Contributing
216
215
 
217
216
  1. Fork it
@@ -4,9 +4,9 @@ $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.7"
8
- gem.authors = ["Yusuke Nomura", "kenjiskywalker"]
9
- gem.email = ["yunomu@gmail.com", "git@kenjiskywalker.org"]
7
+ gem.version = "1.2.8"
8
+ gem.authors = ["Yusuke Nomura", "kenjiskywalker", "FUJIWARA Shunichiro"]
9
+ gem.email = ["yunomu@gmail.com", "git@kenjiskywalker.org", "fujiwara.shunichiro@gmail.com"]
10
10
  gem.description = %q{Input plugin for AWS CloudWatch.}
11
11
  gem.homepage = "https://github.com/yunomu/fluent-plugin-cloudwatch"
12
12
  gem.summary = gem.description
@@ -20,6 +20,7 @@ class Fluent::CloudwatchInput < Fluent::Input
20
20
  config_param :interval, :integer, :default => 300
21
21
  config_param :open_timeout, :integer, :default => 10
22
22
  config_param :read_timeout, :integer, :default => 30
23
+ config_param :delayed_start, :bool, :default => false
23
24
 
24
25
  attr_accessor :dimensions
25
26
 
@@ -52,30 +53,45 @@ class Fluent::CloudwatchInput < Fluent::Input
52
53
  :http_open_timeout => @open_timeout,
53
54
  :http_read_timeout => @read_timeout,
54
55
  )
55
-
56
- @cw = AWS::CloudWatch.new(
57
- :access_key_id => @aws_key_id,
58
- :secret_access_key => @aws_sec_key,
59
- :cloud_watch_endpoint => @cw_endpoint,
60
- ).client
61
56
  end
62
57
 
63
58
  def start
64
59
  super
60
+ @running = true
65
61
  @watcher = Thread.new(&method(:watch))
66
62
  end
67
63
 
68
64
  def shutdown
69
65
  super
66
+ @running = false
70
67
  @watcher.terminate
71
68
  @watcher.join
72
69
  end
73
70
 
74
71
  private
75
72
  def watch
76
- while true
77
- sleep @interval
78
- output
73
+ if @delayed_start
74
+ delay = rand() * @interval
75
+ log.debug("delay at start #{delay} sec")
76
+ sleep(delay)
77
+ end
78
+
79
+ @cw = AWS::CloudWatch.new(
80
+ :access_key_id => @aws_key_id,
81
+ :secret_access_key => @aws_sec_key,
82
+ :cloud_watch_endpoint => @cw_endpoint,
83
+ ).client
84
+
85
+ output
86
+
87
+ started = Time.now
88
+ while @running
89
+ now = Time.now
90
+ sleep 1
91
+ if now - started >= @interval
92
+ output
93
+ started = now
94
+ end
79
95
  end
80
96
  end
81
97
 
@@ -86,7 +102,7 @@ class Fluent::CloudwatchInput < Fluent::Input
86
102
  :metric_name => m,
87
103
  :statistics => [@statistics],
88
104
  :dimensions => @dimensions,
89
- :start_time => (Time.now - @period*5).iso8601,
105
+ :start_time => (Time.now - @period*10).iso8601,
90
106
  :end_time => Time.now.iso8601,
91
107
  :period => @period,
92
108
  })
@@ -102,9 +118,8 @@ class Fluent::CloudwatchInput < Fluent::Input
102
118
  output_data = {m => data}
103
119
  Fluent::Engine.emit(tag, catch_time, output_data)
104
120
  else
105
- log.warn "cloudwatch: statistics[:datapoints] is empty"
121
+ log.warn "cloudwatch: #{@namespace} #{@dimensions_name} #{@dimensions_value} #{m} datapoints is empty"
106
122
  end
107
123
  }
108
- sleep 1
109
124
  end
110
125
  end
@@ -93,4 +93,27 @@ class CloudwatchInputTest < Test::Unit::TestCase
93
93
  assert_equal [{ :name => "GatewayId", :value => "sgw-XXXXXXXX" }, { :name => "GatewayName", :value => "mygateway" }], d.instance.dimensions
94
94
  end
95
95
 
96
+ ### delayed_start
97
+ CONFIG_DELAYED_START = CONFIG_RDS + %[
98
+ delayed_start true
99
+ ]
100
+
101
+ def create_driver_delayed_start(conf = CONFIG_DELAYED_START)
102
+ Fluent::Test::InputTestDriver.new(Fluent::CloudwatchInput).configure(conf)
103
+ end
104
+
105
+ def test_configure_delayed_start
106
+ d = create_driver_delayed_start
107
+ assert_equal 'cloudwatch', d.instance.tag
108
+ assert_equal 'test_key_id', d.instance.aws_key_id
109
+ assert_equal 'test_sec_key', d.instance.aws_sec_key
110
+ assert_equal 'test_cloud_watch_endpoint', d.instance.cw_endpoint
111
+ assert_equal 'AWS/RDS', d.instance.namespace
112
+ assert_equal 'CPUUtilization,FreeStorageSpace,DiskQueueDepth,FreeableMemory,SwapUsage,ReadIOPS,ReadLatency,ReadThroughput,WriteIOPS,WriteLatency,WriteThroughput', d.instance.metric_name
113
+ assert_equal 'DBInstanceIdentifier', d.instance.dimensions_name
114
+ assert_equal 'rds01', d.instance.dimensions_value
115
+ assert_equal [{ :name => 'DBInstanceIdentifier', :value => 'rds01' }], d.instance.dimensions
116
+ assert_equal true, d.instance.delayed_start
117
+ end
118
+
96
119
  end
metadata CHANGED
@@ -1,28 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cloudwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Nomura
8
8
  - kenjiskywalker
9
+ - FUJIWARA Shunichiro
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-06-07 00:00:00.000000000 Z
13
+ date: 2014-09-16 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
17
18
  requirements:
18
- - - ~>
19
+ - - "~>"
19
20
  - !ruby/object:Gem::Version
20
21
  version: 0.10.30
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - ~>
26
+ - - "~>"
26
27
  - !ruby/object:Gem::Version
27
28
  version: 0.10.30
28
29
  - !ruby/object:Gem::Dependency
@@ -43,26 +44,27 @@ dependencies:
43
44
  name: rake
44
45
  requirement: !ruby/object:Gem::Requirement
45
46
  requirements:
46
- - - '>='
47
+ - - ">="
47
48
  - !ruby/object:Gem::Version
48
49
  version: 0.9.2
49
50
  type: :development
50
51
  prerelease: false
51
52
  version_requirements: !ruby/object:Gem::Requirement
52
53
  requirements:
53
- - - '>='
54
+ - - ">="
54
55
  - !ruby/object:Gem::Version
55
56
  version: 0.9.2
56
57
  description: Input plugin for AWS CloudWatch.
57
58
  email:
58
59
  - yunomu@gmail.com
59
60
  - git@kenjiskywalker.org
61
+ - fujiwara.shunichiro@gmail.com
60
62
  executables: []
61
63
  extensions: []
62
64
  extra_rdoc_files: []
63
65
  files:
64
- - .gitignore
65
- - .travis.yml
66
+ - ".gitignore"
67
+ - ".travis.yml"
66
68
  - Gemfile
67
69
  - LICENSE
68
70
  - README.md
@@ -81,17 +83,17 @@ require_paths:
81
83
  - lib
82
84
  required_ruby_version: !ruby/object:Gem::Requirement
83
85
  requirements:
84
- - - '>='
86
+ - - ">="
85
87
  - !ruby/object:Gem::Version
86
88
  version: '0'
87
89
  required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  requirements:
89
- - - '>='
91
+ - - ">="
90
92
  - !ruby/object:Gem::Version
91
93
  version: '0'
92
94
  requirements: []
93
95
  rubyforge_project:
94
- rubygems_version: 2.1.11
96
+ rubygems_version: 2.2.2
95
97
  signing_key:
96
98
  specification_version: 4
97
99
  summary: Input plugin for AWS CloudWatch.