-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove metrics-elb-full in favor of metrics-elb + fix --scheme and --fetch_age #265
Conversation
bin/metrics-elb.rb
Outdated
@@ -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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this technically is also a breaking change and should be called out as well. I'd also suggest that maybe elb names more sense as there are now the following types of load balaners in aws and where possible I'd go for more specific:
- ElasticLoadBalancer
- NetworkLoadBalancer
- ApplicationLoadBalaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the name implies I'd prefer elb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to follow what you are asking for here: would you prefer to have elb
or one of the other more specific name? I guess we could have this scheme auto configured respectively to the actual load balancer being monitored, but in that case I would make that into another PR.
As for the value itself:
- it's a breaking change compared to the
-full
variant, I'll document it in the changelog. - I will change it to
elb
if you prefer. That would be a breaking change for the normal variant as well in this case (which hadloadbalancer
hardcoded.)
bin/metrics-elb.rb
Outdated
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What scenario would this be nil
in other than explicitly setting setting it to nil
? It previously had a default of ''
(empty string) which is not the same as nil:
$ irb
irb(main):001:0> a = ''
=> ""
irb(main):002:0> a.nil?
=> false
I can't see a scenario where it is even possible, it accepts a string value so even if you specified nil I would imagine it would return the string of 'nil'
Also the if should go on the same line as the assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, the test should be on the empty string instead of nil
, I copied/pasted the wrong code from another plugin apparently...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also moved the if
on the same line as the assignment, although it's not very consistent with the other checks :)
bin/metrics-elb.rb
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading through the code it feels to me like fetch_age
should be renamed start_time
does that sound right? If so we are already doing lots of breaking changes and might as well make it make more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below
@@ -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], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this it seems like we should rename fetch_age
to start_time
or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really the start time, it's the duration in the past you want to get the metrics from.
It actually makes more sense than having a start_time
flag:
- using a "fetch age" flag, you don't have to specify the end time and can use a fixed "fetch age" duration to say: every time the check executes, get me the metrics from the last 60 seconds for example:
metrics-elb.rb --fetch_age 60s
- using a "start time" flag, you would need to specify a specific time which would need to be updated every time you are executing the check (otherwise you get the same metrics all the times), which is not especially practical in the context in which Sensu works.
metrics-elb.rb --start-time 2018-02-06T17:45:15+01:00
Does it make more sense?
@majormoses Thanks for the review and sorry for the late reply! There are some conflicts with |
prefer a rebase if you can. |
…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 sensu-plugins#240
6ff1474
to
5e27219
Compare
On Wed, Feb 7, 2018, at 09:04, Ben Abrams wrote:
prefer a rebase if you can.
Just did :)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Great work
Can you also update #240 (comment)? |
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
Pull Request Checklist
I had a look at the
metrics-elb-full.rb
. It's actually very similar tometrics-elb.rb
, beside the SDK version used the differences are:-full
variant properly process the--scheme
flag, whereas the normal variant ignores it-full
variant can look for data in the past using the--fetch_age
flag as an offset respectively to the current time, the normal variant as the same flag which isn't use-full
variant can't-full
variant-full
variant looks up to 60 seconds in the past (--fetch_age
is 60 seconds by default), whereas the normal variant just looks up to the current time.I started to port
metrics-elb-full.rb
to the AWS-SDK v2, but I wondered if it was necessary and if it would be better to just drop this-full
variant in favor of the other one (which is already using AWS-SDK v2). Also, while testing it, I realized it was displaying lot of garbage (see the tests artifacts below). I eventually did the following:metrics-elb-full.rb
(backward incompatibility)metrics-elb-full.rb
tometrics-elb.rb
--fetch_age
flag (backward incompatibility)General
Update Changelog following the conventions laid out here
Update README with any necessary configuration snippets
Binstubs are created if needed
RuboCop passes
Existing tests pass
Purpose
This helps to advance #240
Tests artifacts
Known Compatibility Issues
Documented in the CHANGELOG