How to Monitor Snowflake Credits Usage Effectively
To monitor Snowflake credits, use the
SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY view which tracks credit consumption by warehouses. Query this view regularly to see credit usage over time and identify cost patterns.Syntax
The main way to monitor credits is by querying the WAREHOUSE_METERING_HISTORY view in the SNOWFLAKE.ACCOUNT_USAGE schema. This view shows credit usage per warehouse per time interval.
WAREHOUSE_NAME: The warehouse consuming credits.START_TIME: When the usage interval started.CREDITS_USED: Number of credits consumed in the interval.
sql
SELECT WAREHOUSE_NAME, START_TIME, CREDITS_USED FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP()) ORDER BY START_TIME DESC;
Example
This example query shows total credits used by each warehouse in the last 7 days, helping you track which warehouses consume the most credits.
sql
SELECT WAREHOUSE_NAME, SUM(CREDITS_USED) AS TOTAL_CREDITS_USED FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP()) GROUP BY WAREHOUSE_NAME ORDER BY TOTAL_CREDITS_USED DESC;
Output
WAREHOUSE_NAME | TOTAL_CREDITS_USED
---------------|-------------------
COMPUTE_WH | 125.75
ETL_WH | 98.40
REPORTING_WH | 45.20
Common Pitfalls
Common mistakes when monitoring credits include:
- Querying
ACCOUNT_USAGEviews too frequently, which can cause delays because data refreshes every few minutes. - Not filtering by recent dates, leading to large result sets and slow queries.
- Ignoring warehouse suspend/resume times, which affect credit usage.
Always filter by recent time and aggregate data to get meaningful insights.
sql
/* Wrong: No date filter, large data scan */ SELECT * FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY; /* Right: Filter recent 7 days only */ SELECT * FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP());
Quick Reference
| Field | Description |
|---|---|
| WAREHOUSE_NAME | Name of the warehouse using credits |
| START_TIME | Start time of the usage interval |
| END_TIME | End time of the usage interval |
| CREDITS_USED | Credits consumed during the interval |
| CREDITS_USED_COMPUTE | Credits used for compute only |
| CREDITS_USED_CLOUD_SERVICES | Credits used for cloud services |
Key Takeaways
Use SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY to track credit usage by warehouse.
Filter queries by recent dates to get timely and efficient results.
Aggregate credit usage to understand total consumption per warehouse.
Avoid querying usage views too frequently due to data refresh delays.
Monitor warehouse suspend/resume behavior to optimize credit consumption.
