Skip to main content

Cost Attribution & Chargeback Models

When multiple teams share a Snowflake account, the inevitable question is: "who's spending what?" Without clear cost attribution, you end up with finger-pointing, budget surprises, and no accountability. In this lesson, we'll build a cost attribution framework from tagging through to chargeback reporting.


Why Cost Attribution Matters​

In a single-team setup, the team owns the bill. In multi-team organizations, you need to know which team is spending what and which project is driving a cost spike. Without attribution, the platform team becomes the sole cost center for all analytics. That's neither fair nor sustainable.


Object Tagging for Cost Tracking​

Snowflake's tagging system lets you attach metadata to any object. For cost attribution, we tag warehouses, databases, and schemas with ownership information.

CREATE TAG IF NOT EXISTS cost_center
ALLOWED_VALUES 'engineering', 'marketing', 'finance', 'data-science', 'platform';

CREATE TAG IF NOT EXISTS project
COMMENT = 'Project or initiative name for cost tracking';

Apply these tags to your objects:

ALTER WAREHOUSE analytics_wh SET TAG
cost_center = 'marketing', project = 'customer-360';

ALTER WAREHOUSE etl_wh SET TAG
cost_center = 'engineering', project = 'data-platform';

ALTER DATABASE marketing_db SET TAG cost_center = 'marketing';

Tags propagate through TAG_REFERENCES, making it possible to join cost data with ownership metadata.


QUERY_TAG for Workload Identification​

While object tags cover warehouses and databases, QUERY_TAG lets you attribute costs at the individual query level — useful when multiple teams share a warehouse.

ALTER SESSION SET QUERY_TAG = '{"team":"marketing","pipeline":"campaign_metrics"}';

You can then aggregate QUERY_HISTORY by the tag:

SELECT query_tag, COUNT(*) AS query_count,
SUM(total_elapsed_time) / 1000 AS total_seconds
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE start_time >= DATEADD('day', -30, CURRENT_TIMESTAMP())
AND query_tag IS NOT NULL AND query_tag != ''
GROUP BY query_tag
ORDER BY total_seconds DESC;

A structured JSON format (as shown above) is much more useful than freeform strings — it lets you parse and aggregate by team, pipeline, or any other dimension.


Credit Tracking with Metering Views​

-- Warehouse compute costs by day
SELECT warehouse_name, DATE_TRUNC('day', start_time) AS usage_date,
SUM(credits_used) AS total_credits
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE start_time >= DATEADD('month', -3, CURRENT_TIMESTAMP())
GROUP BY 1, 2 ORDER BY 1, 2;

For all metering including serverless features, use SNOWFLAKE.ACCOUNT_USAGE.METERING_HISTORY with its service_type column.


Serverless Feature Costs​

These features consume credits without a user-managed warehouse, making them easy to overlook:

Serverless FeatureCost DriverMonitoring View
SnowpipeFile volume and frequencyPIPE_USAGE_HISTORY
Auto-clusteringTable size and churn rateAUTOMATIC_CLUSTERING_HISTORY
Materialized viewsMaintenance on base table changesMATERIALIZED_VIEW_REFRESH_HISTORY
Search optimizationIndex maintenanceSEARCH_OPTIMIZATION_HISTORY
ReplicationData volume replicatedREPLICATION_USAGE_HISTORY
Serverless tasksTask execution computeSERVERLESS_TASK_HISTORY
SELECT 'Snowpipe' AS feature, SUM(credits_used) AS credits
FROM SNOWFLAKE.ACCOUNT_USAGE.PIPE_USAGE_HISTORY
WHERE start_time >= DATEADD('month', -1, CURRENT_TIMESTAMP())
UNION ALL
SELECT 'Auto-clustering', SUM(credits_used)
FROM SNOWFLAKE.ACCOUNT_USAGE.AUTOMATIC_CLUSTERING_HISTORY
WHERE start_time >= DATEADD('month', -1, CURRENT_TIMESTAMP())
UNION ALL
SELECT 'Materialized Views', SUM(credits_used)
FROM SNOWFLAKE.ACCOUNT_USAGE.MATERIALIZED_VIEW_REFRESH_HISTORY
WHERE start_time >= DATEADD('month', -1, CURRENT_TIMESTAMP())
ORDER BY credits DESC;

Storage Cost Monitoring​

Storage is billed separately from compute. Track it with:

SELECT table_catalog AS database_name, table_schema, table_name,
ROUND(active_bytes / POWER(1024, 4), 4) AS active_tb,
ROUND(time_travel_bytes / POWER(1024, 4), 4) AS time_travel_tb,
ROUND(failsafe_bytes / POWER(1024, 4), 4) AS failsafe_tb
FROM SNOWFLAKE.ACCOUNT_USAGE.TABLE_STORAGE_METRICS
WHERE active_bytes > 0
ORDER BY (active_bytes + time_travel_bytes + failsafe_bytes) DESC
LIMIT 25;

Time Travel and Fail-safe storage add up fast. A 1 TB table with 90 days of Time Travel and 7 days of Fail-safe can use 3-4x its active storage in total billed bytes.


Data Transfer Costs​

Data transfer costs apply when data moves between Snowflake regions or to external cloud storage:

SELECT source_cloud, source_region, target_cloud, target_region,
SUM(bytes_transferred) / POWER(1024, 4) AS tb_transferred
FROM SNOWFLAKE.ACCOUNT_USAGE.DATA_TRANSFER_HISTORY
WHERE start_time >= DATEADD('month', -3, CURRENT_TIMESTAMP())
GROUP BY 1, 2, 3, 4
ORDER BY tb_transferred DESC;

Cross-region and cross-cloud transfers are the most expensive.


Building a Chargeback Report​

This query joins warehouse metering data with tags to produce a cost-by-team breakdown:

WITH warehouse_tags AS (
SELECT object_name AS warehouse_name, tag_value AS cost_center
FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
WHERE domain = 'WAREHOUSE' AND tag_name = 'COST_CENTER'
),
monthly_credits AS (
SELECT warehouse_name, DATE_TRUNC('month', start_time) AS usage_month,
SUM(credits_used) AS total_credits
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE start_time >= DATEADD('month', -6, CURRENT_TIMESTAMP())
GROUP BY 1, 2
)
SELECT wt.cost_center, mc.usage_month,
SUM(mc.total_credits) AS credits_consumed,
SUM(mc.total_credits) * 3.00 AS estimated_cost_usd -- adjust per contract
FROM monthly_credits mc
JOIN warehouse_tags wt ON mc.warehouse_name = wt.warehouse_name
GROUP BY 1, 2 ORDER BY 2, 4 DESC;

For a complete view, combine this with serverless and storage costs attributed via the same tagging hierarchy.


Dashboard Patterns for Finance Teams​

Structure your chargeback output to answer:

  1. Monthly total by cost center — headline number for each team's budget review
  2. Trend over last 6 months — is spending growing, stable, or declining?
  3. Top 10 most expensive warehouses — where are the big numbers?
  4. Serverless vs. warehouse split — are hidden serverless costs growing?

A scheduled task refreshing a summary table daily works well as backing data for dashboards.


Best Practices for Org-Wide Cost Governance​

Establish tagging standards early. Define your tag taxonomy before teams start creating warehouses.

Make cost visibility a habit. Share chargeback reports monthly with team leads.

Automate untagged object detection:

SELECT w.warehouse_name
FROM (SELECT warehouse_name FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSES
WHERE deleted_on IS NULL) w
LEFT JOIN (SELECT object_name FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
WHERE domain = 'WAREHOUSE' AND tag_name = 'COST_CENTER') t
ON w.warehouse_name = t.object_name
WHERE t.object_name IS NULL;

Don't optimize prematurely. Track costs for at least one billing cycle before making cuts.


Key Takeaways​

  • Tag every warehouse and database with cost center and project metadata from day one.
  • Use structured QUERY_TAG values to attribute shared warehouse costs to specific teams.
  • Monitor serverless feature costs separately — they're easy to miss and can grow quickly.
  • Build automated chargeback reports that join metering history with tag references.
  • Cost governance is a cultural practice, not just a technical one. Visibility drives accountability.