GroupBy Rule

The GroupBy rule creates dynamic elements based on a configured source (or sources)

  • Dimension Element = All values in the Name tag
If (resource has a value in the Name tag) THEN element = Name tag value

Examples of where customers might leverage GroupBy rules:

The GroupBy rule can be confusing at first. Remember that CloudZero is evaluating each resource (conceptually) and trying to assign it a Dimension element via your CostFormation. Whereas the Group rule uses specific logic to determine an Element value, GroupBy uses metadata in your infrastructure to assign an element value (usually tags). The GroupBy rule won't have logic conditions, it creates Dimension elements from the source values.

  • You have 1 "real" environment tag that engineers are supposed to use and 2 other environment tags that are legacy and/or mistakes. You want to create a Dimension which brings all these tags together including a prioritization of the tags.

  • You're building a dimension for product. You have a tag called Product but there's other logic that will improve the business context. 1 account is entirely associated to product = "Analytics" and you need to change a legacy tag value from "Reactor" to "Resource Ingest".


Micro-Learning

-- Duration: 2 Minutes

-- Topics Covered:
       -- GroupBy Rule Syntax
       -- Example Rule




Using Multiple Sources For Your GroupBy Rule

You can list multiple sources with a GroupBy rule. 95% of the time, the GroupBy rule is used to “coalesce” sources together. 5% of the time, your use case requires the values of the different sources get “concatenated”.

For the the following examples of coalesce vs concatenate, consider the following resource data:

ResourceAccountServiceTag:EnvironmentTag:envTag:environment
Resource1931830253924EC2ProductionProd-1Prod-1
Resource2931830253924EC2Prd

“Coalesce” - This means that when evaluating any given resource, make the Dimension’s element be the value from the first non-NULL source. You indicate this by adding a “CoalesceSources: True” at the bottom of the dimension

  • If you’re coalescing sources, the sources will be considered in priority order. This is important because any given resource might have values for multiple sources. What happens if the resource has values for both sources? The dimension element will be selected from the higher priority source
  • Considering the resource data in the table above, Resource1 would get an Environment dimension = “Production”. Resource 2 would get an Environment dimension = “Prd”

“Concatenate” - This means that when evaluating any given resource, make the Dimension’s element be a combination of all the source values. If you don’t include a “CoalesceSources: True” then the Dimension’s behavior will be to concatenate. Note that when taking this approach, only resources with values for all sources will be considered.

  • Consider the same dimension but without the “CoalesceSources: True”. Now the behavior will be to combine the values from the different sources
  • Considering the resource data in the table above, Resource1 would get an Environment dimension = "ProductionProd-1Prod-1". Resource2 wouldn't get any element value because concatenate only takes into account resources that have values in all the sources

As you can imagine, "concatenate" doesn’t normally result in element names that are very nice. When concatenating, most customers will use the Format property to control the output:

  • Using the Format property you can take the values from the different sources and display them however you want.
  • Considering the resource data in the table above, Resource1 would get an Environment dimension = "Production :: Prod-1 :: Prod-1". Resource2 wouldn't get any element value because concatenate only takes into account resources that have values in all the sources