Attributing cost

An organization can gain insight into the cost of using Snowflake by attributing those costs to logical units within the organization (e.g. departments, environments, and projects). This chargeback or showback model is useful for accounting purposes, but it also allows an organization to identify which units are spending the most. This insight helps pinpoint areas of the organization that could benefit from controls and optimizations in order to reduce costs.

Attribute cost of individual resources

The most direct, powerful way to attribute cost to different groupings like departments, environments, or projects is to tag specific resources using the object tagging feature. In this strategy, an administrator creates a tag (e.g. cost_center), then defines a list of possible values of the tag (e.g. sales, finance). In this example, each cost center gets a unique tag value. The tag/value combination is then assigned to resources used by a cost center. As these resources consume credits, you can run reports grouped by the tag value. Because this tag value corresponds directly to a particular grouping within the organization, costs can be attributed accurately.

Object tagging allows you to attribute cost based on something as general as an account or as specific as a table. Note that not all taggable objects accumulate cost. From a cost management perspective, tagging an object only makes sense if there is a schema view that contains usage or cost data related to that object. For a list of Snowflake usage and cost views, see Exploring overall cost.

Attribution workflow

Using object tags to attribute cost consists of three basic tasks:

  1. Design a tagging strategy and create the appropriate tags.

  2. Tag resources with the correct tag/value pair.

  3. Run reports based on usage and tag data.

To help illustrate this workflow, consider a Snowflake account that:

  • Has two cost centers: Sales and finance.

  • Has three warehouses. Sales uses Warehouse1 and Warehouse2, while the finance department uses Warehouse3.

Three warehouses in an account

In this example, the goal is to attribute warehouse costs associated with each warehouse to the appropriate department.

Note

The following example assumes that appropriate privileges have been granted to the role tag_admin. An organization can use the granular tagging permissions to develop a secure tagging strategy.

Task 1: Design tagging strategy and create the appropriate tags

For this example, an administrator with the proper privileges creates a single tag called cost_center.

USE ROLE tag_admin;
USE SCHEMA my_db.my_schema;
CREATE TAG cost_center;
Copy
Task 2: Tag objects with the correct tag/value pair

The tag administrator applies the appropriate tag/value pair to the warehouses. For example, since the sales department uses both warehouse1 and warehouse2, the same tag/value combination is applied to these two resources.

USE ROLE tag_admin;
ALTER WAREHOUSE warehouse1 SET TAG cost_center='SALES';
ALTER WAREHOUSE warehouse2 SET TAG cost_center='SALES';
ALTER WAREHOUSE warehouse3 SET TAG cost_center='FINANCE';
Copy

Note

If administrators want to control which values can be set on the object, they can use the optional allowed_values parameter when creating the tag. For details, see CREATE TAG.

Task 3: Run reports based on usage and tag data

You can attribute costs by reporting on the use of resources that have the cost_center tag. This data is available in Snowsight, or by querying the SNOWFLAKE.ACCOUNT_USAGE schema.

Snowsight:
  1. Switch to a role that has access to the ACCOUNT_USAGE schema.

  2. Navigate to Admin » Cost Management.

  3. Select Consumption.

  4. From the Tags drop-down, select the cost_center tag.

  5. To focus on a specific cost center, select a value from the list of the tag’s values.

  6. Select Apply.

For more details about filtering in Snowsight, see Filter by tag.

SQL:

The Account Usage schema contains data about both resource usage and the tags in the schema. Executing a query against views in this schema attributes credit consumption by the warehouses to the correct cost center.

USE snowflake.account_usage;

SELECT tag_value AS cost_center,
  SUM(credits_used)
FROM warehouse_metering_history, tag_references
WHERE warehouse_name=object_name
  AND tag_name='COST_CENTER'
GROUP BY 1
ORDER BY 2 DESC;
Copy

The query returns a report like:

COST_CENTER

CREDITS_USED

SALES

17.173333333

FINANCE

8.14444444

For complete details about using object tags, see Object Tagging.