The flow shows how Snowflake credit usage is monitored by querying usage data, checking thresholds, and alerting if limits are exceeded.
Execution Sample
Snowflake
SELECT WAREHOUSE_NAME, SUM(CREDITS_USED) AS TOTAL_CREDITS
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE START_TIME >= DATEADD(day, -1, CURRENT_TIMESTAMP())
GROUP BY WAREHOUSE_NAME;
This query sums credits used by each warehouse in the last day to monitor credit consumption.
Process Table
Step
Action
Query/Check
Result
Next Step
1
Start Monitoring
N/A
Monitoring started
Query credit usage
2
Query Credit Usage Table
Run SELECT on WAREHOUSE_METERING_HISTORY
Returns credits used per warehouse
Fetch current usage
3
Fetch Current Credit Usage
Sum credits for last 24 hours
Warehouse A: 50, Warehouse B: 30
Compare usage to threshold
4
Compare Usage to Threshold
Is any usage > 40 credits?
Warehouse A: Yes, Warehouse B: No
Alert admin for Warehouse A
5
Alert Admin
Send alert for Warehouse A
Alert sent
Wait and repeat monitoring
6
Wait and Repeat
Pause for monitoring interval
Wait complete
Start Monitoring again
7
End Monitoring
Condition to stop monitoring met
Monitoring stopped
N/A
💡 Monitoring stops when manual stop or condition met; otherwise repeats.
Status Tracker
Variable
Start
After Step 3
After Step 4
Final
Warehouse A Credits
0
50
50
50
Warehouse B Credits
0
30
30
30
Alert Sent
No
No
Yes
Yes
Key Moments - 3 Insights
Why do we sum credits used over the last 24 hours instead of total credits?
Summing credits over the last 24 hours (see execution_table step 3) helps monitor recent usage and detect spikes quickly, rather than looking at all-time totals which may hide current trends.
What happens if no warehouse exceeds the threshold?
If no warehouse exceeds the threshold (execution_table step 4 shows 'No' for Warehouse B), no alert is sent and the system waits before checking again, ensuring no false alarms.
How often should the monitoring repeat?
The monitoring repeats after a pause (step 6), which can be set based on business needs, e.g., every hour or day, to balance timely alerts and resource use.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, which warehouse triggers an alert?
ABoth Warehouse A and B
BWarehouse B
CWarehouse A
DNo warehouse triggers alert
💡 Hint
Check the 'Result' column at step 4 showing usage compared to threshold.
At which step does the system send an alert to the admin?
AStep 5
BStep 2
CStep 4
DStep 6
💡 Hint
Look for the step labeled 'Alert Admin' in the execution_table.
If Warehouse B's credits increased to 45, how would the execution_table change at step 4?
AAlert would be sent only for Warehouse B
BWarehouse B would also be marked 'Yes' for exceeding threshold
CNo change, only Warehouse A triggers alert
DMonitoring would stop immediately
💡 Hint
Refer to step 4 where usage is compared to threshold for each warehouse.
Concept Snapshot
Credit Usage Monitoring in Snowflake:
- Query WAREHOUSE_METERING_HISTORY for credits used
- Sum credits over recent period (e.g., last 24 hours)
- Compare usage to alert threshold
- Send alert if usage exceeds threshold
- Repeat monitoring at set intervals
Full Transcript
Credit usage monitoring in Snowflake involves running a query on the warehouse metering history to sum credits used by each warehouse over a recent time frame, such as the last 24 hours. The system then compares these sums to a predefined threshold. If any warehouse exceeds the threshold, an alert is sent to notify administrators. If not, the system waits for a set interval before repeating the monitoring process. This cycle continues until monitoring is stopped manually or by condition.