0
0
Snowflakecloud~5 mins

Resource monitors for cost control in Snowflake - Commands & Configuration

Choose your learning style9 modes available
Introduction
Resource monitors help you keep track of how much computing power your Snowflake account uses. They stop you from spending too much by setting limits on usage.
When you want to avoid unexpected high bills from running too many queries.
When you need to set a monthly budget for your Snowflake data warehouse usage.
When you want to get alerts before your account reaches a spending limit.
When you want to automatically suspend warehouses to save costs after a limit is reached.
When you manage multiple teams and want to control their resource usage separately.
Config File - resource_monitor.sql
resource_monitor.sql
CREATE RESOURCE MONITOR my_monitor
  WITH CREDIT_QUOTA = 100
  TRIGGERS ON 80 PERCENT DO NOTIFY,
           ON 100 PERCENT DO SUSPEND;

ALTER ACCOUNT SET RESOURCE_MONITOR = my_monitor;

This SQL script creates a resource monitor named my_monitor with a credit limit of 100 credits.

It sets two triggers: when 80% of the limit is reached, it sends a notification; when 100% is reached, it suspends warehouses to stop further usage.

The last command attaches this monitor to the Snowflake account so it starts controlling usage.

Commands
This command creates a resource monitor named 'my_monitor' with a limit of 100 credits. It sets triggers to notify at 80% usage and suspend warehouses at 100%.
Terminal
snowsql -q "CREATE RESOURCE MONITOR my_monitor WITH CREDIT_QUOTA = 100 TRIGGERS ON 80 PERCENT DO NOTIFY, ON 100 PERCENT DO SUSPEND;"
Expected OutputExpected
Resource monitor MY_MONITOR created.
This command attaches the resource monitor 'my_monitor' to the Snowflake account so it starts monitoring usage.
Terminal
snowsql -q "ALTER ACCOUNT SET RESOURCE_MONITOR = my_monitor;"
Expected OutputExpected
Account altered.
This command checks the details of the resource monitor to verify it was created and attached correctly.
Terminal
snowsql -q "SHOW RESOURCE MONITORS LIKE 'my_monitor';"
Expected OutputExpected
name | credit_quota | used_credits | state MY_MONITOR | 100 | 0 | ACTIVE
Key Concept

If you remember nothing else from this pattern, remember: resource monitors let you set credit limits and actions to control Snowflake costs automatically.

Common Mistakes
Not attaching the resource monitor to the account after creating it.
The monitor won't control usage or send alerts unless it is linked to the account.
Always run ALTER ACCOUNT SET RESOURCE_MONITOR = your_monitor_name after creating the monitor.
Setting triggers without specifying actions like NOTIFY or SUSPEND.
Triggers without actions do nothing and won't help control costs.
Always define what happens at each trigger level, such as NOTIFY or SUSPEND.
Summary
Create a resource monitor with a credit limit and triggers for notifications and suspending warehouses.
Attach the resource monitor to your Snowflake account to activate cost control.
Verify the monitor status with a SHOW command to ensure it is active and tracking usage.