-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix bug: too many cloudwatch metrics #1885
Conversation
b39b1b6
to
d838221
Compare
Hi, maintainers. Do you have any feedback about this pull request? We have a workaround for ourselves, but it would be nice to get this fix merged. |
from what I can tell there appears to be overlap between #1885 and #1903. I would appreciate if one of you could open an issue with a full writeup on what exactly is wrong the cloudwatch plugin. As this plugin is particularly difficult to reproduce problems on, please be sure to include examples of requests and responses, and links to documentation where necessary. Please also provide concrete examples that illustrate what is wrong with the current behavior of the plugin. If I am wrong and there isn't overlap, then feel free to open two separate issues. In either case I think they need to be seen and discussed before I can accept a PR changing the behavior of this plugin. |
@sparrc I looked at this change and it looks correct. I verified using the provided spec. What is happening currently is that when using wildcard dimensions, the metric is selected multiple times because it has an inner loop that ranges over all available metrics from the Cloudwatch API but it doesn't compare that it's looking at the same metric that's configured. So if I have this:
and Cloudwatch is returning:
then the code is currently doing:
So the change here is correct in that it first checks that we are comparing our selected metric against only those metrics in cloudwatch of the same name. |
} | ||
for _, name := range m.MetricNames { | ||
for _, metric := range allMetrics { | ||
if isSelected(metric, m.Dimensions) { | ||
if name == *metric.MetricName && isSelected(metric, m.Dimensions) { |
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.
The name logic check should just be folded into the isSelected
method.
So, isSelected(name, metric, m.Dimensions)
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.
Done
OK, fair enough, thanks for the review @johnrengelman |
Thanks for taking a close look at my fix. I'll try to be more complete in explanations in future pull requests. |
e4e1fb4
to
b5babc9
Compare
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.
Looks good, just update the changelog and I'll get it merged
@@ -55,6 +55,7 @@ continue sending logs to /var/log/telegraf/telegraf.log. | |||
|
|||
### Bugfixes | |||
|
|||
- [#1885](https://github.com/influxdata/telegraf/pull/1885): Fix over-querying of cloudwatch metrics |
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.
move this into "features" under the 1.2 section
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.
done
Cloudwatch metrics were being added incorrectly. The most obvious symptom of this was that too many metrics were being added. A simple check against the name of the metric proved to be a sufficient fix. In order to test the fix, a metric selection function was factored out.
315768c
to
83b8e80
Compare
* Fix bug: too many cloudwatch metrics Cloudwatch metrics were being added incorrectly. The most obvious symptom of this was that too many metrics were being added. A simple check against the name of the metric proved to be a sufficient fix. In order to test the fix, a metric selection function was factored out. * Go fmt cloudwatch * Cloudwatch isSelected checks metric name * Move cloudwatch line in changelog to 1.2 features
* Fix bug: too many cloudwatch metrics Cloudwatch metrics were being added incorrectly. The most obvious symptom of this was that too many metrics were being added. A simple check against the name of the metric proved to be a sufficient fix. In order to test the fix, a metric selection function was factored out. * Go fmt cloudwatch * Cloudwatch isSelected checks metric name * Move cloudwatch line in changelog to 1.2 features
Cloudwatch metrics were being added incorrectly. The most obvious
symptom of this was that too many metrics were being added. A simple
check against the name of the metric proved to be a sufficient fix. In
order to test the fix, a metric selection function was factored out.