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.
The name logic check should just be folded into the isSelected method.
So, isSelected(name, metric, m.Dimensions)
|
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
sparrc
left a comment
There was a problem hiding this comment.
Looks good, just update the changelog and I'll get it merged
CHANGELOG.md
Outdated
|
|
||
| ### Bugfixes | ||
|
|
||
| - [#1885](https://github.com/influxdata/telegraf/pull/1885): Fix over-querying of cloudwatch metrics |
There was a problem hiding this comment.
move this into "features" under the 1.2 section
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.