logstash-input-cloudwatch 1.0.1 → 1.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: 8e95131861e3d73ddd1d47e955321d0686248716
4
- data.tar.gz: 361ec5a82fbe63eada201d138246e399656454ef
3
+ metadata.gz: 714fb9324b667cc5e6318beea884232eec399de7
4
+ data.tar.gz: eb9fcaced10b0ff797bdb956aef90f1d4f622538
5
5
  SHA512:
6
- metadata.gz: 45715e6fa60d4a73fec3662cbd44a04a0f1105d72ec6726cf9fc4de5016a0ace20707a50009f0c30fce543260e87c3afbc43be8177addd2d6cde021990962a02
7
- data.tar.gz: dc7b7f6cc21e2ba8965437d0d2a9f0e9c73777054a56dba51c594740c7676e31dca693b6960d7a827dd82082c46c5b208971d185db3a0d39380bae6360170de4
6
+ metadata.gz: b0979483d18a9c984d9705557ab534f8d0fc382aed2f5b6ccd83bf2884b84e3dc72bba7bc4f5f1188e08c5dfaa7727ee584c135132c9e9597ce6417adcf008b7
7
+ data.tar.gz: 37fd5c701c206fa282a547f07517b599e77f20584394243983893acfe8669aa12cf8ea3ac9ef82f68e39b7297e2e1e72ef63b419fe1409aebb726d061c9c5f82
@@ -109,6 +109,9 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
109
109
  # to ensure you're using valid filters.
110
110
  config :filters, :validate => :array
111
111
 
112
+ # Use this for namespaces that need to combine the dimensions like S3 and SNS.
113
+ config :combined, :validate => :boolean, :default => false
114
+
112
115
  public
113
116
  def aws_service_endpoint(region)
114
117
  { region: region }
@@ -119,8 +122,10 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
119
122
  require "aws-sdk"
120
123
  AWS.config(:logger => @logger)
121
124
 
122
- # Initialize all the clients
123
- [@namespace, 'CloudWatch'].each { |ns| clients[ns] }
125
+ raise 'Unsupported namespace ' + @namespace unless @namespace[0..3] == 'AWS/'
126
+ raise 'Interval needs to be higher than period' unless @interval >= @period
127
+ raise 'Interval must be divisible by peruid' unless @interval % @period == 0
128
+
124
129
  @last_check = Time.now
125
130
  end # def register
126
131
 
@@ -133,21 +138,45 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
133
138
  # For every metric
134
139
  metrics_for(@namespace).each do |metric|
135
140
  @logger.info "Polling metric #{metric}"
136
- # For every dimension in the metric
137
- resources.each_pair do |dimension, dim_resources|
138
- # For every resource in the dimension
139
- dim_resources = *dim_resources
140
- dim_resources.each do |resource|
141
- # For every event in the resource
142
- fetch_resource_events(dimension, resource, metric_options(@namespace, metric)).each do |event|
143
- queue << event
144
- end
145
- end
146
- end
141
+ @logger.info "Filters: #{aws_filters}"
142
+ @combined ? from_filters(queue, metric) : from_resources(queue, metric)
147
143
  end
148
144
  end # loop
149
145
  end # def run
150
146
 
147
+ def from_resources(queue, metric)
148
+ # For every dimension in the metric
149
+ resources.each_pair do |dimension, dim_resources|
150
+ # For every resource in the dimension
151
+ dim_resources = *dim_resources
152
+ dim_resources.each do |resource|
153
+ # For every event in the resource
154
+ fetch_resource_events(dimension, resource, metric_options(@namespace, metric)).each do |event|
155
+ queue << event
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ private
162
+ def from_filters(queue, metric)
163
+ options = metric_options(@namespace, metric)
164
+ options[:dimensions] = aws_filters
165
+ @logger.info "Dim: #{options[:dimensions]}"
166
+ datapoints = clients['CloudWatch'].get_metric_statistics(options)
167
+ @logger.debug "DPs: #{datapoints.data}"
168
+ datapoints[:datapoints].each do |event|
169
+ event.merge! options
170
+ aws_filters.each do |dimension|
171
+ event[dimension[:name].to_sym] = dimension[:value]
172
+ end
173
+ event = LogStash::Event.new(cleanup(event))
174
+ decorate(event)
175
+ queue << event
176
+ end
177
+ end
178
+
179
+ private
151
180
  def fetch_resource_events(dimension, resource, options)
152
181
  @logger.info "Polling resource #{dimension}: #{resource}"
153
182
  options[:dimensions] = [ { name: dimension, value: resource } ]
@@ -161,6 +190,7 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
161
190
  end
162
191
  end
163
192
 
193
+ private
164
194
  def cleanup(event)
165
195
  event.delete :statistics
166
196
  event.delete :dimensions
@@ -213,15 +243,18 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
213
243
  private
214
244
  def aws_filters
215
245
  @filters.collect do |key, value|
216
- value = [value] unless value.is_a? Array
217
- { name: key, values: value }
246
+ if ['AWS/EC2', 'AWS/EBS'].include?(@namespace)
247
+ value = [value] unless value.is_a? Array
248
+ { name: key, values: value }
249
+ else
250
+ { name: key, value: value }
251
+ end
218
252
  end
219
253
  end
220
254
 
221
255
  private
222
256
  def resources
223
257
  # See http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html
224
- @logger.info "Filters: #{aws_filters}"
225
258
  case @namespace
226
259
  when 'AWS/EC2'
227
260
  instances = clients[@namespace].describe_instances(filters: aws_filters)[:reservation_set].collect do |r|
@@ -235,7 +268,7 @@ class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base
235
268
  end.flatten
236
269
  @logger.debug "AWS/EBS Volumes: #{volumes}"
237
270
  { 'VolumeId' => volumes }
238
- when 'AWS/RDS'
271
+ else
239
272
  @filters
240
273
  end
241
274
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-cloudwatch'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.3'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Retrieve stats from AWS CloudWatch."
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,98 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-cloudwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.4.0
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
23
- requirement: !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
24
26
  requirements:
25
- - - '>='
27
+ - - ">="
26
28
  - !ruby/object:Gem::Version
27
29
  version: 1.4.0
28
- - - <
30
+ - - "<"
29
31
  - !ruby/object:Gem::Version
30
32
  version: 3.0.0
31
- prerelease: false
32
- type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: logstash-codec-plain
35
- version_requirements: !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
- requirement: !ruby/object:Gem::Requirement
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
41
43
  requirements:
42
- - - '>='
44
+ - - ">="
43
45
  - !ruby/object:Gem::Version
44
46
  version: '0'
45
- prerelease: false
46
- type: :runtime
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: stud
49
- version_requirements: !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.0.19
54
- requirement: !ruby/object:Gem::Requirement
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
55
57
  requirements:
56
- - - '>='
58
+ - - ">="
57
59
  - !ruby/object:Gem::Version
58
60
  version: 0.0.19
59
- prerelease: false
60
- type: :runtime
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: logstash-mixin-aws
63
- version_requirements: !ruby/object:Gem::Requirement
63
+ requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
- requirement: !ruby/object:Gem::Requirement
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
69
71
  requirements:
70
- - - '>='
72
+ - - ">="
71
73
  - !ruby/object:Gem::Version
72
74
  version: '0'
73
- prerelease: false
74
- type: :runtime
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: logstash-devutils
77
- version_requirements: !ruby/object:Gem::Requirement
77
+ requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: 0.0.16
82
- requirement: !ruby/object:Gem::Requirement
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
83
85
  requirements:
84
- - - '>='
86
+ - - ">="
85
87
  - !ruby/object:Gem::Version
86
88
  version: 0.0.16
87
- prerelease: false
88
- type: :development
89
- description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
89
+ description: This gem is a logstash plugin required to be installed on top of the
90
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
91
+ a stand-alone program
90
92
  email: jrgns@eagerelk.com
91
93
  executables: []
92
94
  extensions: []
93
95
  extra_rdoc_files: []
94
96
  files:
95
- - .gitignore
97
+ - ".gitignore"
96
98
  - CHANGELOG.md
97
99
  - DEVELOPER.md
98
100
  - Gemfile
@@ -108,24 +110,24 @@ licenses:
108
110
  metadata:
109
111
  logstash_plugin: 'true'
110
112
  logstash_group: input
111
- post_install_message:
113
+ post_install_message:
112
114
  rdoc_options: []
113
115
  require_paths:
114
116
  - lib
115
117
  required_ruby_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - '>='
119
+ - - ">="
118
120
  - !ruby/object:Gem::Version
119
121
  version: '0'
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  requirements:
122
- - - '>='
124
+ - - ">="
123
125
  - !ruby/object:Gem::Version
124
126
  version: '0'
125
127
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.4.5
128
- signing_key:
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.6
130
+ signing_key:
129
131
  specification_version: 4
130
132
  summary: Retrieve stats from AWS CloudWatch.
131
133
  test_files: