-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[AWS][Billing] Support Configurable Group By Types #38755
base: main
Are you sure you want to change the base?
[AWS][Billing] Support Configurable Group By Types #38755
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
This pull request is now in conflicts. Could you fix it? 🙏
|
This pull request is now in conflicts. Could you fix it? 🙏
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services) |
This pull request is now in conflicts. Could you fix it? 🙏
|
@elastic/obs-ds-hosted-services could you review this PR? |
I think @elastic/obs-infraobs-integrations might be involved here as they own the AWS Billing module |
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.
Approving the code for data plane (subject to fixing the CI, which looks like it will just require a make check
and a changelog update), but make sure you also get infraobs approval for the user-visible content of the feature.
Adding @gpop63 to review. |
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.
Let's get the CI to pass, probably need to run make update
.
_, _ = event.RootFields.Put("aws.linked_account.name", name) | ||
|
||
// index 0 is the key for the primary group_by | ||
if index == 0 { |
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.
Are we sure these keys are always returned in consistent order? Wasn't the previous check safer?
* *group_by_primary_type* The type of group for the primary keys, supports either `DIMENSION` or `TAG`. Default `DIMENSION`. | ||
* *group_by_primary_keys* A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_primary_type*. | ||
* *group_by_secondary_type* The type of group for the secondary keys, supports either `DIMENSION` or `TAG`. Default `TAG`. | ||
* *group_by_secondary_keys* A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_secondary_type*. |
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.
Let's keep the old settings as well and specify that they are deprecated in favor of the new settings.
* *group_by_primary_type* The type of group for the primary keys, supports either `DIMENSION` or `TAG`. Default `DIMENSION`. | |
* *group_by_primary_keys* A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_primary_type*. | |
* *group_by_secondary_type* The type of group for the secondary keys, supports either `DIMENSION` or `TAG`. Default `TAG`. | |
* *group_by_secondary_keys* A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_secondary_type*. | |
* *group_by_dimension_keys*: Deprecated, please use `group_by_primary_type` or `group_by_secondary_type`. | |
* *group_by_tag_keys*: Deprecated, please use `group_by_primary_type` or `group_by_secondary_type`. | |
* *group_by_primary_type*: The type of group for the primary keys, supports either `DIMENSION` or `TAG`. Default `DIMENSION`. | |
* *group_by_primary_keys*: A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_primary_type*. | |
* *group_by_secondary_type*: The type of group for the secondary keys, supports either `DIMENSION` or `TAG`. Default `TAG`. | |
* *group_by_secondary_keys*: A list of keys used in Cost Explorer to group by. It can either by a list of dimension values or a list of tags, but needs to match the type set by *group_by_secondary_type*. |
// handle bwc with old config | ||
if len(config.CostExplorerConfig.GroupByPrimaryKeys) == 0 && len(config.CostExplorerConfig.GroupByDimensionKeys) > 0 { | ||
config.CostExplorerConfig.GroupByPrimaryKeys = config.CostExplorerConfig.GroupByDimensionKeys | ||
} | ||
if len(config.CostExplorerConfig.GroupBySecondaryKeys) == 0 && len(config.CostExplorerConfig.GroupByTagKeys) > 0 { | ||
config.CostExplorerConfig.GroupBySecondaryKeys = config.CostExplorerConfig.GroupByTagKeys | ||
} |
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.
Will this fetch the exact same data from AWS as before?
return nil | ||
} | ||
|
||
// validateGroupByType checks if a string value for group_by type is a supported value. | ||
func validateGroupByType(groupByType costexplorertypes.GroupDefinitionType) (bool, error) { |
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.
Can't this function just return an error instead of (bool, error)
?
if config.CostExplorerConfig.GroupByPrimaryType == "" { | ||
config.CostExplorerConfig.GroupByPrimaryType = defaultGroupByPrimaryType | ||
} | ||
if config.CostExplorerConfig.GroupBySecondaryType == "" { | ||
config.CostExplorerConfig.GroupBySecondaryType = defaultGroupBySecondaryType | ||
} |
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.
Do we want to group the data by default? Shouldn't this be decided by the user?
Enhancement
Proposed commit message
WHAT: Implements the ability to configure the AWS Billing modules "Group By" values. Previously these were hardcoded to
DIMENSION
andTAG
. But AWS supports defining any combo of these values.WHY: Expands the use-cases that the AWS Billing module can support.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
DIMENSION
&TAG
setup.group_by_dimension_keys
&group_by_tag_keys
have been marked as deprecated, and are only referenced if the new config valuesgroup_by_primary_keys
&group_by_secondary_keys
are unset.supportedDimensionKeys
as they were last touched ~4 years ago and were out-of-date)How to test this PR locally
main
and run it with a config. This run will be used as the "baseline" for validating this PR.Base Config used for Testing
Base Config used for Testing (no changes to data should be observed)
New Config with two dimension keys
New Config with two dimension keys (more keys)
New Config with two tag keys
New Config using new config values, with two dimensions
Related issues
Use cases
Screenshots
Logs