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

Update CommitmentDiscountUsage transform to use parse_resourceid #1219

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_resources/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Legend:
> ✏️ Changed:
>
> 1. Update required permissions on hubs page [Required permissions](../docs/_reporting/hubs/README.md).
> 2. Updated `CommitmentDiscountUsage_transform_v1_0()` to use `parse_resourceid()`.

πŸ” Optimization engine
{: .fs-5 .fw-500 .mt-4 mb-0 }
Expand Down
12 changes: 5 additions & 7 deletions src/templates/finops-hub/modules/scripts/IngestionSetup.kql
Original file line number Diff line number Diff line change
Expand Up @@ -1245,12 +1245,10 @@ CommitmentDiscountUsage_transform_v1_0()
//
// Handle resource columns
| extend ResourceId = tolower(InstanceId)
// TODO: Switch to use parse_resourceid()
| parse ResourceId with "/subscriptions/" SubAccountId "/resourcegroups/" x_ResourceGroupName "/providers/" tmp_ResourceProvider "/" tmp_ResourceProviderPath
| extend segments = split(tmp_ResourceProviderPath, '/')
| mv-apply element = segments on (extend index = row_number() | where index % 2 == 0 | summarize ResourceName = strcat_array(make_list(element), '/'))
| mv-apply element = segments on (extend index = row_number() | where index % 2 == 1 | summarize x_ResourceType = strcat_array(make_list(element), '/'))
| extend x_ResourceType = strcat(tmp_ResourceProvider, '/', x_ResourceType)
| extend tmp_ResourceDetails = parse_resourceid(ResourceId)
| extend SubAccountId = tmp_ResourceDetails.SubAccountId
| extend x_ResourceGroupName = tmp_ResourceDetails.x_ResourceGroupName
| extend x_ResourceType = tmp_ResourceDetails.x_ResourceType
| lookup kind=leftouter (ResourceTypes | distinct x_ResourceType, ResourceType = SingularDisplayName) on x_ResourceType
| lookup kind=leftouter (Services | distinct x_ResourceType, ServiceName, ServiceCategory, x_ServiceModel) on x_ResourceType
//
Expand All @@ -1276,7 +1274,7 @@ CommitmentDiscountUsage_transform_v1_0()
x_CommitmentDiscountNormalizedRatio = InstanceFlexibilityRatio,
x_CommitmentDiscountQuantity = UsedHours * InstanceFlexibilityRatio,
x_IngestionTime = ingestion_time(), // Hubs add-on
x_ResourceGroupName = extract('/resourcegroups/([^/]+)/', 1, ResourceId),
x_ResourceGroupName,
x_ResourceType,
// x_RowId = hash_sha256(strcat(
// // DO NOT CHANGE COLUMNS OR COLUMN ORDER
Expand Down