How to Assign and Manage Resource Monitors in Snowflake


Snowflake provides a robust mechanism to monitor and control credit usage across your account through resource monitors. These monitors help manage virtual warehouses’ usage, ensuring budget adherence and preventing unexpected costs. This article delves into the assignment and management of resource monitors, offering practical insights for optimizing credit usage and avoiding pitfalls.

What Are Resource Monitors?

Resource monitors are tools in Snowflake that track and manage credit consumption at the account or warehouse level. They enable administrators to:

Set quotas for credit usage.

Define actions (e.g., suspend warehouses) when thresholds are met.
Notify users when credit usage reaches specific levels.

Key Concepts in Resource Monitor Assignment

  1. Account-Level vs. Warehouse-Level Monitors
  • Account-Level Monitor:
    Tracks credit usage for all warehouses in the account.
    Example: A quota of 5000 credits for all warehouses combined in a given interval.

  • Warehouse-Level Monitor:
    Monitors individual or grouped warehouses.
    Each warehouse can only be assigned to one resource monitor below the account level.

2. Quota and Thresholds

  • Quotas define the maximum credits allowed in an interval (daily, weekly, monthly, etc.).
  • Actions can be triggered when usage hits predefined thresholds, such as NOTIFY, SUSPEND, or SUSPEND IMMEDIATE.

3. Warehouse Suspension and Cloud Services

  • When a warehouse is suspended, active queries are completed (unless suspension is immediate).
  • Cloud services (e.g., Snowpipe) continue to incur costs even if associated warehouses are suspended.

Example Scenarios of Resource Monitor Assignments

Scenario: Hybrid Monitor Assignment

Imagine an account with five warehouses and the following setup:

  • Resource Monitor 1 (Account Level): Sets a 5000-credit quota for all warehouses.
  • Resource Monitor 2: Assigns a 1000-credit limit specifically to Warehouse 3.
  • Resource Monitor 3: Assigns a combined 2500-credit limit to Warehouses 4 and 5.

Outcomes:

  1. If Resource Monitor 1 reaches 5000 credits, all warehouses are suspended regardless of individual quotas.
  2. If Warehouse 3 exceeds 1000 credits, only Warehouse 3 is suspended.
  3. Warehouses 4 and 5 share their 2500-credit quota; if either exceeds this, both are suspended.

Best Practices for Managing Resource Monitors

1. Set Realistic Thresholds
To avoid unintended suspensions, configure thresholds conservatively (e.g., 90% instead of 100% of the quota).
2. One Warehouse per Monitor
Assign a single warehouse to each monitor for stricter control over individual usage.
3. Enable Notifications
Proactively monitor credit usage by enabling email notifications or dashboard alerts.
4. Monitor Cloud Services Costs
Keep an eye on additional charges from cloud services, as these are not directly controlled by resource monitors.

Creating and Modifying Resource Monitors

Using the Web Interface

  1. Navigate to Admin → Cost Management → Resource Monitors.
  2. Select + Resource Monitor to create a monitor.
  3. Set a Name, Credit Quota, and Interval (daily, weekly, monthly, etc.).
  4. Choose whether the monitor is for the Account or specific Warehouses.
  5. Add actions and notifications at desired thresholds.

Using SQL
Create resource monitors with fine-tuned control:

— Create a monitor for 1000 credits with suspension at 90% and immediate suspension at 100%
CREATE OR REPLACE RESOURCE MONITOR my_monitor
WITH CREDIT_QUOTA = 1000
TRIGGERS
ON 90 PERCENT DO SUSPEND
ON 100 PERCENT DO SUSPEND_IMMEDIATE;

— Assign the monitor to a warehouse
ALTER WAREHOUSE my_warehouse SET RESOURCE_MONITOR = my_monitor;
Modify an existing monitor:

— Increase the credit quota to 1500
ALTER RESOURCE MONITOR my_monitor SET CREDIT_QUOTA = 1500;

Enabling Notifications

Snowsight:

  1. Profile → Notifications.
  2. Verify your email address.
  3. Enable notifications for resource monitors.

Classic Console:

  1. Navigate to Preferences → Notifications.
  2. Select the desired notification options.

Common Challenges and Solutions

Challenge 1: Credits Exceed Quota Despite Suspension

Solution: Snowflake may take time to suspend a warehouse after the threshold is reached. Add buffer thresholds (e.g., suspend at 90% instead of 100%).

Challenge 2: Monitoring Cloud Services Costs

Solution: Regularly review credit usage reports to identify unexpected cloud services costs.

FAQs
1. Can a resource monitor enforce hourly credit limits?
No, resource monitors work at broader intervals (day, week, month). For tighter control, use conservative thresholds and monitor usage frequently.

2. Do resource monitors impact serverless features?
Account-level monitors do not control serverless features like Snowpipe. Additional monitoring may be needed.

  1. Can non-admin users receive notifications?
    Yes, but only for warehouse monitors. Their email must be verified, and they need to be added to the monitor’s notification list.

Conclusion
Resource monitors in Snowflake are powerful tools to manage and optimize credit usage effectively. By understanding their functionality, setting proper thresholds, and leveraging notifications, you can maintain control over your Snowflake costs while avoiding operational disruptions. Whether you’re managing a single warehouse or an enterprise-scale account, these practices will ensure a seamless, cost-efficient experience.


Leave a Reply

Your email address will not be published. Required fields are marked *