[AWS][Billing] Support Configurable Group By Types#38755
[AWS][Billing] Support Configurable Group By Types#38755BenB196 wants to merge 25 commits intoelastic:mainfrom
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 |
Adding @gpop63 to review. |
gpop63
left a comment
There was a problem hiding this comment.
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.
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.
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.
Will this fetch the exact same data from AWS as before?
| } | ||
|
|
||
| // 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.
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.
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
DIMENSIONandTAG. But AWS supports defining any combo of these values.WHY: Expands the use-cases that the AWS Billing module can support.
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
DIMENSION&TAGsetup.group_by_dimension_keys&group_by_tag_keyshave been marked as deprecated, and are only referenced if the new config valuesgroup_by_primary_keys&group_by_secondary_keysare unset.supportedDimensionKeysas they were last touched ~4 years ago and were out-of-date)How to test this PR locally
mainand 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