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.
Snowflake offers a flexible set of cost attribution features that enable organizations to attribute cost at any level of the Snowflake object hierarchy. These features can attribute credit consumption to groupings like cost centers, environments, and projects. Snowflake provides the following attribution strategies:
Object tagging can provide granular attribution that allows you to assign the cost of using individual resources like a warehouse or database to a specific unit within the organization.
Executing queries can attribute warehouse usage by role, user, or query, which is particularly helpful when multiple cost centers share the same warehouse.
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
cost_center), then defines a list of possible values of the tag (e.g.
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.
Using object tags to attribute cost consists of three basic tasks:
Design a tagging strategy and create the appropriate tags.
Tag resources with the correct tag/value pair.
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.
In this example, the goal is to attribute warehouse costs associated with each warehouse to the appropriate department.
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
use role tag_admin; use schema my_db.my_schema; create tag cost_center;
- 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
warehouse2, the same tag/value combination is applied to these two resources.
If administrators want to control which values can be set on the object, they can use the optional
allowed_valuesparameter when creating the tag. For details, see CREATE TAG.
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';
- 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_centertag. This data is available in Snowsight, the Snowflake web interface, or by querying the
Switch to a role that has access to the ACCOUNT_USAGE schema.
Navigate to Admin » Usage.
From the Tags drop-down, select the
To focus on a specific cost center, select a value from the list of the tag’s values.
For more details about filtering in Snowsight, see Filter by Tag.
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.
The query returns a report like:
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;
For complete details about using object tags, see Object Tagging.