Skip to content

Commit

Permalink
Remove metrics-elb-full in favor of metrics-elb + fix --scheme and --…
Browse files Browse the repository at this point in the history
…fetch_age

Both were doing mostly the same, in slightly different ways.

Once fixed, metrics-elb.rb has more features than metrics-elb-full.rb
(such as --period and --statistics, which are not available in the `-full`
variant) and supports the AWS-SDK v2, which helps for #240
  • Loading branch information
multani authored and majormoses committed Feb 9, 2018
1 parent e1c2bf0 commit e7fa6c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 150 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Breaking Changes
- metrics-elb-full.rb: removed in favor of metrics-elb.rb, which is slightly more configurable and uses the AWS-SDK v2 already. Compared to metrics-elb-full.rb, metrics-elb.rb no longer takes --aws-access-key, --aws-secret-access-key flags, Authentication should be configured per [here](https://github.com/sensu-plugins/sensu-plugins-aws/blob/master/README.md#authentication) (@multani)
- metrics-elb.rb: honors the --fetch_age flag which now looks up values 60 seconds in the past by default. This was the intended behavior, as documented in the NOTES section (@multani)

### Fixed
- metrics-elb.rb: properly handle the --scheme and --fetch_age flags (@multani)

## [10.2.0] - 2018-01-20
### Added
Expand Down
145 changes: 0 additions & 145 deletions bin/metrics-elb-full.rb

This file was deleted.

19 changes: 14 additions & 5 deletions bin/metrics-elb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
description: 'Metric naming scheme, text to prepend to metric',
short: '-s SCHEME',
long: '--scheme SCHEME',
default: ''
default: 'loadbalancer'

option :fetch_age,
description: 'How long ago to fetch metrics for',
Expand Down Expand Up @@ -106,8 +106,8 @@ def cloud_watch_metric(metric_name, value, load_balancer_name)
}
],
statistics: [value],
start_time: config[:end_time] - config[:period],
end_time: config[:end_time],
start_time: config[:end_time] - config[:fetch_age] - config[:period],
end_time: config[:end_time] - config[:fetch_age],
period: config[:period]
)
end
Expand All @@ -117,8 +117,17 @@ def print_statistics(load_balancer_name, statistics)
static_value = {}
statistics.each do |key, static|
r = cloud_watch_metric(key, static, load_balancer_name)
static_value['loadbalancer.' + load_balancer_name + '.' + key + '.' + static] = static
result['loadbalancer.' + load_balancer_name + '.' + key + '.' + static] = r[:datapoints][0] unless r[:datapoints][0].nil?
keys =
if config[:scheme].nil?
[]
else
[config[:scheme]]
end
keys.concat [load_balancer_name, key, static]
metric_key = keys.join('.')

static_value[metric_key] = static
result[metric_key] = r[:datapoints][0] unless r[:datapoints][0].nil?
end
result.each do |key, value|
output key.downcase.to_s, value[static_value[key].downcase], value[:timestamp].to_i
Expand Down

0 comments on commit e7fa6c9

Please sign in to comment.