-
Notifications
You must be signed in to change notification settings - Fork 5k
Collect Cloudwatch metrics from the same timestamp #11142
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f9078c0
Update aws documentation
1041e42
Add checks for instance fields in TestFetch
9a4accc
Add changelog for timestamp fix
c233d4c
Add FindTimestamp method to get timestamp for all metrics
eea1f3f
Add tests for CheckTimestampInArray and FindTimestamp
263b458
Update comment for CheckTimestampInArray
0d0e1da
Change test to table driven
0bd2f0b
Remove labels length check
5837888
Remove old comments
3f4d339
Adopt CheckTimestampInArray and FindTimestamp in S3 and SQS
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,14 +205,20 @@ func createS3RequestEvents(outputs []cloudwatch.MetricDataResult, regionName str | |
|
|
||
| // AWS s3_request metrics | ||
| mapOfMetricSetFieldResults := make(map[string]interface{}) | ||
|
|
||
| // Find a timestamp for all metrics in output | ||
| if len(outputs) > 0 && len(outputs[0].Timestamps) > 0 { | ||
| timestamp := outputs[0].Timestamps[0] | ||
| timestamp := aws.FindTimestamp(outputs) | ||
| if !timestamp.IsZero() { | ||
| for _, output := range outputs { | ||
| labels := strings.Split(*output.Label, " ") | ||
| // check timestamp to make sure metrics come from the same timestamp | ||
| if len(labels) == 3 && labels[0] == bucketName && len(output.Values) > 0 && output.Timestamps[0] == timestamp { | ||
| mapOfMetricSetFieldResults[labels[2]] = fmt.Sprint(output.Values[0]) | ||
| if len(output.Values) == 0 { | ||
| continue | ||
| } | ||
| exists, timestampIdx := aws.CheckTimestampInArray(timestamp, output.Timestamps) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this code is identical to the code in the s3 daily storage file? Perhaps later we can take it out. |
||
| if exists { | ||
| labels := strings.Split(*output.Label, " ") | ||
| if labels[0] == bucketName && len(output.Values) > timestampIdx { | ||
| mapOfMetricSetFieldResults[labels[2]] = fmt.Sprint(output.Values[timestampIdx]) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,15 +180,22 @@ func createEventPerQueue(getMetricDataResults []cloudwatch.MetricDataResult, que | |
|
|
||
| // AWS sqs metrics | ||
| mapOfMetricSetFieldResults := make(map[string]interface{}) | ||
| for _, output := range getMetricDataResults { | ||
| if len(output.Values) == 0 { | ||
| continue | ||
| } | ||
| labels := strings.Split(*output.Label, " ") | ||
| if labels[0] != queueName { | ||
| continue | ||
|
|
||
| // Find a timestamp for all metrics in output | ||
| timestamp := aws.FindTimestamp(getMetricDataResults) | ||
| if !timestamp.IsZero() { | ||
| for _, output := range getMetricDataResults { | ||
| if len(output.Values) == 0 { | ||
| continue | ||
| } | ||
| exists, timestampIdx := aws.CheckTimestampInArray(timestamp, output.Timestamps) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more time the same code? :-) |
||
| if exists { | ||
| labels := strings.Split(*output.Label, " ") | ||
| if labels[0] == queueName && len(output.Values) > timestampIdx { | ||
| mapOfMetricSetFieldResults[labels[1]] = fmt.Sprint(output.Values[timestampIdx]) | ||
| } | ||
| } | ||
| } | ||
| mapOfMetricSetFieldResults[labels[1]] = fmt.Sprint(output.Values[0]) | ||
| } | ||
|
|
||
| resultMetricSetFields, err := aws.EventMapping(mapOfMetricSetFieldResults, schemaMetricFields) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.