Skip to content
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

Default config metrics exporter #233

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

jefchien
Copy link
Contributor

@jefchien jefchien commented Jun 15, 2021

Description of the issue

In order to support EC2 metrics published by the CW Agent on Metrics Explorer, the dimensions of the metrics should be set as "Instance Id". This is something we achieve for the existing customers using some guideline docs. But for new customers who will onboard for the first time, we would like to offer this support by default by arranging these settings in the CW Agent config file.

Description of changes

Added a yes/no prompt in defaultConfig.go as part of the config wizard to add the aggregation_dimensions field to the metrics config. By default, the aggregation_dimensions will have a single dimension of "Instance Id". Moved pricing disclaimer from prompt to welcome message.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Updated defaultConfig_test.go to account for the additional prompt and added the aggregation_dimensions field to the expected.
Tested the validity of the generated config and performed end-to-end test.

@jefchien jefchien requested review from pingleig and pxaws June 15, 2021 21:50
Copy link
Member

@pingleig pingleig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of format related diffs, I guess we didn't run go fmt on all files when we export them to github in first release? @haojhcwa

return "aggregation_dimensions", config.Dimensions
}

func (config *AggregationDimensions) SetDefaultDimensions() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you only call SetDefault... in this file? Maybe just inline the func manually. Also we might have a constant string for InstanceId defined somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only used in a single place, so inlining does make sense. I was following appendDimensions.go, so it'd probably make sense to change it in both places.

There's a constant string for InstanceId defined in ruleInstanceId.go, but it doesn't seem like it's used anywhere else except for within that file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hard code the string here is fine, you can add a constant within this file/package if you want to.

tool/data/config/metrics_test.go Show resolved Hide resolved
Copy link
Member

@pingleig pingleig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but still need to wait @pxaws on the config translator logic before merging it.

Also @jefchien please update the description after you have validated the config generated by new wizard is working end to end. i.e. run the wizard and see right cw metrics dimension in console.

@@ -29,6 +31,17 @@ func (config *Metrics) ToMap(ctx *runtime.Context) (string, map[string]interface
}
}

if config.AggregationDimensions == nil && ctx.WantAggregateDimensions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this assume that the new added option should not coexist with other option like WantEC2TagDimensions? Do we ensure that in the wizard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't prevent WantEC2TagDimensions from coexisting. It just adds a separate prompt to add the AggregationDimensions. I believe that based on the documentation for setting up the config for metric explorer (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metrics-Explorer.html), both the WantEC2TagDimensions and WantAggregateDimensions options are required during setup, but I felt that keeping the two options separate made sense if they weren't configuring with that purpose in mind. The default would include both.

@pxaws
Copy link
Contributor

pxaws commented Jun 16, 2021

As @pingleig suggested, once you confirm that this works from end to end, we can merge the PR.

@pingleig
Copy link
Member

@jefchien any update on this?

@jefchien
Copy link
Contributor Author

@pingleig Sorry for the delay. I've validated the configuration and behavior. Feel free to merge it when ready.

@pingleig pingleig merged commit cdd177d into aws:master Jun 29, 2021
@pingleig
Copy link
Member

@jefchien btw: remember to add milestone for this PR

@jefchien jefchien added this to the v1.247348.1 milestone Jun 29, 2021
@jefchien jefchien deleted the default-config-metrics-exporter branch June 29, 2021 22:36
@pingleig
Copy link
Member

@jefchien it seems the test are failing, though we do have flaky tests ... https://github.com/aws/amazon-cloudwatch-agent/actions/runs/984367255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants