0
0
Snowflakecloud~5 mins

Credit usage monitoring in Snowflake - Commands & Configuration

Choose your learning style9 modes available
Introduction
Snowflake charges based on credits used for compute resources. Monitoring credit usage helps control costs and avoid surprises on your bill.
When you want to track how many credits your team or project is using daily.
When you need to set alerts before your credit usage exceeds budget limits.
When you want to analyze which warehouses consume the most credits.
When you want to optimize warehouse sizes or schedules based on usage patterns.
When you want to report credit usage to management regularly.
Commands
Select the warehouse to run queries that will check credit usage.
Terminal
USE WAREHOUSE COMPUTE_WH;
Expected OutputExpected
Warehouse changed.
Query the last 7 days of credit usage per warehouse to see daily consumption.
Terminal
SELECT WAREHOUSE_NAME, SUM(CREDITS_USED) AS TOTAL_CREDITS, DATE_TRUNC('day', START_TIME) AS DAY FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP()) GROUP BY WAREHOUSE_NAME, DAY ORDER BY DAY DESC;
Expected OutputExpected
WAREHOUSE_NAME | TOTAL_CREDITS | DAY COMPUTE_WH | 12.5 | 2024-06-20 COMPUTE_WH | 10.0 | 2024-06-19 ANALYTICS_WH | 8.0 | 2024-06-20 ANALYTICS_WH | 7.5 | 2024-06-19
Get total credits used across all warehouses in the last 7 days for overall cost monitoring.
Terminal
SELECT SUM(CREDITS_USED) AS WEEKLY_CREDITS FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP());
Expected OutputExpected
WEEKLY_CREDITS 38.0
Calculate average daily credit usage per warehouse over the last 30 days to identify heavy users.
Terminal
SELECT WAREHOUSE_NAME, AVG(CREDITS_USED) AS AVG_DAILY_CREDITS FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY WHERE START_TIME >= DATEADD(day, -30, CURRENT_TIMESTAMP()) GROUP BY WAREHOUSE_NAME ORDER BY AVG_DAILY_CREDITS DESC;
Expected OutputExpected
WAREHOUSE_NAME | AVG_DAILY_CREDITS COMPUTE_WH | 11.2 ANALYTICS_WH | 7.8
Key Concept

If you remember nothing else from this pattern, remember: querying the WAREHOUSE_METERING_HISTORY view lets you track credit usage over time to control costs.

Common Mistakes
Querying credit usage without filtering by recent dates.
This returns all historical data, which can be huge and slow, making it hard to see current usage.
Always filter by a recent time window like the last 7 or 30 days to get relevant data.
Not grouping credit usage by warehouse or day.
This hides which warehouses or days used the most credits, making it hard to optimize.
Group by warehouse and day to see detailed usage patterns.
Summary
Use the SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY view to monitor credit usage.
Filter queries by recent dates to focus on current usage and avoid large data scans.
Group results by warehouse and day to identify usage patterns and optimize costs.