Advanced Dimension Features
This page covers advanced CloudZero Dimension capabilities for complex cost allocation and categorization scenarios. While the examples show configurations using the Dimension Studio Visual Editor, these concepts apply equally to CostFormation YAML definitions.
Most users won't need these features when getting started. They're designed for sophisticated use cases like:
- Nested allocations that split costs at multiple levels of granularity
- Complex conditional logic with multiple layers of AND/OR/NOT operators
- Advanced data normalization using chained transforms
- Multi-tier weighted distributions based on business hierarchies
If you're new to Dimensions, start with the Dimension Studio overview or Understanding and Writing Rules guide first.
ForEachElementOf (Nested Allocation)
What it does: Enables splitting costs separately within each group, creating nested allocations.
When to use it: You want to allocate costs at multiple levels of granularity.
Example use case: Allocate Kubernetes costs by namespace, then within each namespace, further allocate by team.
How to Configure ForEachElementOf
In an Allocate By Rules dimension:
- After configuring Across Elements, scroll to the bottom
- Click + Add ForEachElementOf
- Configure the nested allocation:
- Dimension: Select the dimension to iterate over (for example, "Namespace")
- Allocation rules: Define how to split costs within each group
ForEachElementOf Example
Scenario: You have Kubernetes costs that should be:
- First allocated by namespace (each namespace gets its proportional share)
- Then within each namespace, allocated by team based on pod count
Configuration:
Allocate By Rules Dimension: "K8s Cost Allocation"
Spend To Allocate:
- Service Category = Container
- Platform = Kubernetes
Across Elements:
Rule 1 (GroupBy):
- Sources: [Namespace]
- Format: {0}
ForEachElementOf: Namespace
Allocation Method: Proportional
Across Elements:
Rule 1 (GroupBy):
- Sources: [Team Tag]
- Format: {0}
Weight by: Pod Count metric
Result:
- Namespace "prod-api" costs $10,000
- Team A (60 pods, 60%): $6,000
- Team B (40 pods, 40%): $4,000
- Namespace "prod-web" costs $5,000
- Team C (50 pods, 100%): $5,000
Condition Group Deep Dive
For the most complex conditional logic, you can nest multiple condition groups within each other.
Multi-Level Nesting Example
Scenario: Create a "High-Value Production Resources" category with complex criteria.
Requirements:
- Must be in production OR critical environments
- Must be in priority regions (us-east-1 or eu-west-1) OR tagged as critical
- Must NOT be temporary or test resources
Configuration:
Type: Group
Name: High-Value Production Resources
Logic: And
Condition Group 1 (Or): Environment Check
- Source: Environment Tag = production
- Source: Environment Tag = critical
Condition Group 2 (Or): Location/Priority Check
- Source: Region in [us-east-1, eu-west-1]
- Source: Resource Tag = critical-priority
Condition Group 3 (Not): Exclusions
Nested Group (Or):
- Source: Resource Tag contains "temp"
- Source: Resource Tag contains "test"
- Source: TTL Tag is not empty
How it evaluates:
IF (production OR critical environment)
AND (in priority regions OR tagged critical)
AND NOT (temporary OR test resources)
THEN categorize as "High-Value Production Resources"
Advanced Transform Combinations
You can chain multiple transforms together for complex data normalization.
Multi-Transform Example
Scenario: Your resource tags are inconsistent: ENV:PROD, env-Production, environment_prod_us, PROD-ENV.
Configuration:
Type: Group
Name: Production
Source: Environment Tag
Transforms (applied in order):
1. Normalize (converts special chars to dashes, lowercases)
2. Split (delimiter: -, index: 0)
Conditions:
- Value: prod
- Value: production
How it processes:
"ENV:PROD" → Normalize → "env-prod" → Split(-, 0) → "env" → no match
"env-Production" → Normalize → "env-production" → Split(-, 0) → "env" → no match
"PROD-ENV" → Normalize → "prod-env" → Split(-, 0) → "prod" → MATCH
"environment_prod_us" → Normalize → "environment-prod-us" → Split(-, 0) → "environment" → no match
Better approach for this scenario: Use index 1 or adjust your rule to match "env" as well, depending on your data patterns.
Complex Allocation Scenarios
Scenario: Multi-Tier Proportional Allocation
Use case: Allocate shared infrastructure costs across team tiers (Enterprise, Professional, Starter) based on each tier's existing cloud spend.
Configuration:
Allocate By Rules Dimension: "Tiered Infrastructure Allocation"
Allocation Method: Proportional
Spend To Allocate:
- Account Name = shared-infrastructure
- Service Category in [Compute, Storage, Networking]
Across Elements:
Rule 1 (Group):
Name: Enterprise-Infrastructure
Conditions:
- Team Tier Tag = Enterprise
Rule 2 (Group):
Name: Professional-Infrastructure
Conditions:
- Team Tier Tag = Professional
Rule 3 (Group):
Name: Starter-Infrastructure
Conditions:
- Team Tier Tag = Starter
How it works: CloudZero automatically calculates each tier's proportion of total cloud spend, then allocates shared infrastructure costs using those same proportions.
Example result: If Enterprise teams represent 60% of total cloud spend, Professional 30%, and Starter 10%, shared infrastructure costs of $10,000 would be allocated:
- Enterprise-Infrastructure: $6,000 (60%)
- Professional-Infrastructure: $3,000 (30%)
- Starter-Infrastructure: $1,000 (10%)
Note: For explicit weight-based allocation (e.g., fixed 50/30/20 split regardless of actual spend), you'll need to use CostFormation YAML with manual weight configuration.
Updated about 5 hours ago
