Bird
Raised Fist0
SnowflakeHow-ToBeginner · 4 min read

How to Use Resource Monitor in Snowflake: Step-by-Step Guide

Use CREATE RESOURCE MONITOR to set credit limits and thresholds in Snowflake. Assign it to warehouses with ALTER WAREHOUSE SET RESOURCE MONITOR to track and control credit consumption automatically.
📐

Syntax

The CREATE RESOURCE MONITOR command defines a monitor with credit limits and notification thresholds. You can specify the total credits allowed, and percentages at which alerts or suspensions occur.

The ALTER WAREHOUSE SET RESOURCE MONITOR command links the monitor to a warehouse to enforce limits.

sql
CREATE RESOURCE MONITOR <resource_monitor_name>
  WITH CREDIT_QUOTA = <number_of_credits>
  [ TRIGGERS ON <percentage> PERCENT DO <action> [,...] ];

ALTER WAREHOUSE <warehouse_name> SET RESOURCE MONITOR = <resource_monitor_name>;
💻

Example

This example creates a resource monitor named my_monitor with a 100 credit limit. It sends an alert at 50% usage and suspends the warehouse at 100%. Then it assigns the monitor to the warehouse my_warehouse.

sql
CREATE RESOURCE MONITOR my_monitor
  WITH CREDIT_QUOTA = 100
  TRIGGERS ON 50 PERCENT DO NOTIFY,
           ON 100 PERCENT DO SUSPEND;

ALTER WAREHOUSE my_warehouse SET RESOURCE MONITOR = my_monitor;
Output
Resource monitor MY_MONITOR created. Warehouse MY_WAREHOUSE altered.
⚠️

Common Pitfalls

  • Not assigning the resource monitor to warehouses means it won't control credit usage.
  • Setting too low credit quotas can suspend warehouses prematurely, disrupting work.
  • Forgetting to set notification triggers can cause missed alerts before suspension.
sql
/* Wrong: Created monitor but not assigned to warehouse */
CREATE RESOURCE MONITOR monitor1 WITH CREDIT_QUOTA = 50;

/* Right: Assign monitor to warehouse */
ALTER WAREHOUSE warehouse1 SET RESOURCE MONITOR = monitor1;
📊

Quick Reference

CommandPurpose
CREATE RESOURCE MONITORCreate a new resource monitor with credit limits and triggers
ALTER WAREHOUSE SET RESOURCE MONITORAssign a resource monitor to a warehouse
SHOW RESOURCE MONITORSList all resource monitors and their status
DROP RESOURCE MONITORDelete a resource monitor
✅

Key Takeaways

Create a resource monitor to set credit limits and control warehouse usage.
Assign the monitor to warehouses to enforce limits and receive alerts.
Use triggers to notify or suspend warehouses at set credit usage percentages.
Monitor credit consumption regularly to avoid unexpected suspensions.
Always test resource monitor settings in a non-production environment first.