Documentation

Custom Labels

Custom Labels Overview

How are custom labels useful:

Your organizations might have business reasons which require that you slice and dice the data in a specific way. This is hard to do because your raw cloud billing data might not have the appropriate tags that you need. Custom labels allows you to label the billing data to:

  • Define the essential functional relationships between different parts of the business
  • Tie cloud assets and their associated costs to business operations

This then gives you the ability to see costs in terms of how you actually run your business.

Here you can Create New Custom Label:

Once you click on that, you’ll see a pop up appear:

Let’s walk through what each of the fields mean:

Existing Label Key

These are the labels that are in the billing export that are available to you. The labels that are available to you are:

  • Systems Labels
  • Project Labels
  • Resource Labels
  • Project IDs
  • Billing Account IDs

Note: At this stage, you need to type in your label exactly as it appears in your billing export. Otherwise it won’t recognize the key.

To differentiate between system-, project- and resource-labels that exist natively in the billing export, Ternary has prefixed the additional labels with "ternary.app/".


Existing Label Value

These are simply all the values that are associated with a ‘key’ that you select from any of the above categories of labels available to you.

New Custom Label Key

This the new key or category you wish to create. Simply type in the key name that you would like.

Custom Label keys must satisfy the following criteria:

  • start with a lowercase letter

  • be composed of only lowercase letters (international allowed), numbers or characters: _ - . /

  • be sixty-four characters in length or shorter

  • for a given Custom Label, all keys must be unique (no duplicates)

  • may not start with "ternary.app/" as this prefix is reserved by Ternary

In addition to these rules, the number of unique Custom Label keys must be no larger than 100 across all Clouds.

New Custom Label Value

This is the label that’s associated with the new key that you just created.

Custom Label values must satisfy the following criteria:

  • be composed of only lowercase letters (international allowed), numbers characters: _ - . /

  • be sixty-four characters in length or shorter

What the logic is saying:

The logic is basically saying this:

If {EXISTING KEY} equals one of {EXISTING LABEL VALUES} THEN assign this {NEW KEY} with this {NEW LABEL VALUE}.

Let’s walk through an example to see how this would work in practice.

Let’s say you you have the following project IDs:

  1. Gcp-project-prod-1
  2. Gcp-project-prod-2
  3. Gcp-project-prod-3
  4. Gcp-project-prod-4

You want to roll up these projects in the following way:

  1. Project 1,2,3 belong to Cost Center: Cost of Revenue
  2. Project 4 belongs to Cost Center: Special Test
  3. All the projects are in development environment: Prod

You would like to see what is the cost for:

  1. Each Cost Center
  2. The total cost of everything that’s Prod related

Here you would apply the labels in the following manner:

Step 1:

Pick Existing Label Key: Project ID (this is the key that you want to roll up)

Step 2: Pick all the projects that are associated with the cost center: Cost of Revenue Label (in this case Projects 1,2,3)

Step 3: In Custom Labels Section. Create a New Custom Key “Cost_Center”

Step 4: In Custom Labels Sections. Assign Value “Cost_of_Revenue’

Now, since projects 1,2,3 ALSO belong to dev environment: Prod, you should also:

Step 5: In Custom Labels Section. Create a New Custom Key “dev_environment”

Step 4: In Custom Labels Sections. Assign Value “prod’

This is what your output would look like:


Once you click ‘Submit’, you’ll see the rule in the existing set of rules.

Now you need to do the same with the remaining project:


Once you’ve created a label, it can then be used to filter different data views within Ternary. For instance, let’s say you go to the home page, and you want to see costs associated with a specific set of labels that you’ve created. You can use the consumer side custom labels feature to apply the filter to the data on the Home Page.

There also is functionality to edit or delete labels rules that you’ve created.

Operators:

There are three different operators available to support matching label values of different types.

"equals" - Match the exact string.

"fuzzy_equals" - Like equals, but the asterisk character * will match any sequence of any characters.

"regex_matches" - Matches if and only if the input string contains a match for the input regex pattern.

As of 7 Oct 2021, the UI only supports the "equals" operator, but the remaining operators are available via API.

Sort Key:
The sort_key field influences the order in which Custom Labels are applied. Those with lower sort_keys are applied first and higher later. This empowers composition of Custom Labels. For example, if multiple projects roll up into a team and multiple teams roll up into a platoon, this can be accomplished with two sets of Custom Labels with sort_keys 1 and 2 respectively. The order in which Custom Labels with the same sort_key are applied is nondetermistic. If you do not care the order in which your Custom Labels are evaluated, any sort_key will work.

As of 13 Oct 2021, the UI does not allow specification of the sort_key and all Custom Labels created within the UI have the same sort_key.

Consumer Side Labels:

This is the place where you go to be able to filter your data and views based on existing labels that you have or new ones that you’ve created.

You can access it by clicking on the top right section here:

Once you click this, a pop up will appear:

If we continue with our previous example. If you want to filter your data to show only data associated with “cost_center: cost_of_revenue”, you simply type in the new created key:value pair and that filter will apply.

It would look like this:

Once you apply the filter, you’ll be able to view what filters you have applied as you navigate to different pages within Ternary

Table-based Custom Labels

Ternary's Custom Labels let users express complex rules to re-tag cost or usage based on original label or column values ingested from the cloud provider. However, these mappings can quickly balloon in number. Take for example a company with hundreds of AWS accounts, each belonging to a specific engineering team. Although each individual mapping is simple (e.g. if account_id equals "123456789", then add a label "team=foobar"`), when these mappings are many, they can become difficult to manage in the Ternary Custom Labels UI.

With table-based Custom Labels, a user may efficiently onboard and maintain a large number of labels by configuring Ternary to reference a BigQuery table for custom label definitions. The following shows the table contents a user might integrate in order to create table-based custom labels, keyed on account_id, making it possible to group spend by cost_center and account owner.

Each row could have been implemented as a single custom label created in the UI, but the table-based Custom Label is an effective alternative to create and manage the custom labels in bulk.

account_idcost_centerowner
000000000150000[email protected]
000000000250001[email protected]
000000000350002[email protected]
000000000450003[email protected]
000000000550004[email protected]
000000000650005[email protected]
000000000750006[email protected]
000000000850007[email protected]

Consult our API documentation or create a Ternary Customer Success ticket (Click 'Help' in Ternary) to learn more about using TBCLs to categorize your spend at scale.

Custom Groupings

Our Custom Groupings functionality allows you to create a new grouping with 2 or more existing vendor labels. This can be used for things like resolving misspellings of labels (ie; environment, enviornment, env,) into a single grouping or changing a set of labels into a single grouping.

Adding a new grouping

Click the "New Grouping" icon -> Row #1 will be created -> Add a Group Name (for example, Environment) -> Select the Labels you want to include in the new Grouping -> Click Submit -> You will receive an "Operation Successful! The custom grouping has been successfully created" once complete

Using your new Custom Grouping in TRE

Once you have created 1 or more Custom Groupings. You can now use these custom groupings in the Ternary Reporting Engine.