Resource Monitor
5 0
Read Time:3 Minute, 49 Second

Resource Monitor, helps control costs and avoid unexpected credit usage caused by running warehouses. The number of credits consumed depends on the size of the warehouse and how long it runs.

Limits set for a specific interval or date range. When these limits are reaches and/or are approaching, resource monitor can trigger various actions. For instance such as sending alert notifications and/or suspending the warehouses.

Resource monitors can only be create by account administrators (i.e. users with the ACCOUNTADMIN role);

Resource Monitor
Credit Quota:

Credit quota specifies the number of Snowflake credits allocated to the monitor for the specified frequency interval. Any number can be specified. At the specified interval, this number resets back to 0. Credit quota accounts for credits consumed by both user-managed virtual warehouses and virtual warehouses used by cloud services.

For example, Monitor limit set at 1000 credits, if your warehouse consumes 700 credits, and cloud services consume 300 credits within a specified interval or date range, an alert will trigger.

Monitor Level:

This property specifies whether the Resource monitor use to monitor the credit usage for your entire Account (i.e. all warehouses in the account) or a specific set of individual warehouses.

If this property not set, the resource monitor doesn’t monitor any credit usage. It simply remains dormant.

Schedule:

The default schedule for a resource monitor specifies that it starts monitoring credit usage immediately and the used credits reset back to 0 at the beginning of each calendar month (i.e. the start of the standard Snowflake billing cycle).

However, you can optionally customize the schedule for a resource monitor using the following properties:

Frequency:

Supported values:

  • Daily
  • Weekly
  • Monthly
  • Yearly
  • Never (used credits never reset; assigned warehouses continue using credits until the credit quota is reached)
ACTIONS: Resource monitors support the following actions:
Actions

Resource monitors support the following actions:

Notify & Suspend:

Send a notification (to all account administrators with notifications enabled) and suspend all assigned warehouses after all statements being executed by the warehouse(s) have completed.

Notify & Suspend Immediately:

Send a notification (to all account administrators with notifications enabled) and suspend all assigned warehouses immediately, which cancels any statements being executed by the warehouses at the time.

Notify:

Perform no action, but send an alert notification (to all account administrators with notifications enabled)

A resource monitor must have at least one action defined; if no actions have been defined, nothing happens when the used credits reach the threshold.

Each resource monitor supports up to a maximum of 5 NOTIFY action triggers.

 

To create a monitor that starts monitoring immediately, resets at the beginning of each month, 
and suspends the assigned warehouse assigned when the used credits reach 100% of the credit quota:
*/

use role accountadmin;

create or replace resource monitor monitor1 with credit_quota=15
triggers on 100 percent do suspend;

alter warehouse compute_wh set resource_monitor = monitor1;


/*
To create a monitor that is similar to the first example, but suspends at 90% 
 and suspends immediately at 100% to prevent all warehouses in the account from consuming credits after the quota has been reached:
*/

use role accountadmin;

create or replace resource monitor monitor2 with credit_quota=100
  triggers on 90 percent do suspend
           on 100 percent do suspend_immediate;

alter warehouse compute_wh set resource_monitor = monitor2;


/*
To create a monitor that is similar to the first example, but lets the assigned warehouse exceed the quota by 10% 
and also includes two notification actions to alert account administrators as the used credits reach the halfway and three-quarters points for the quota:
*/
use role accountadmin;

create or replace resource monitor monitor3 with credit_quota=120
   triggers on 50 percent do notify
            on 75 percent do notify
          on 100 percent do suspend
            on 110 percent do suspend_immediate;

alter warehouse compute_wh set resource_monitor = monitor3;


/*
To create a resource monitor that starts at a specific date and time in the future, resets weekly on the same day and time, 
has no end date or time, and performs two different suspend actions at different thresholds on two assigned warehouses:
*/

use role accountadmin;

create or replace resource monitor monitor_freq2 with credit_quota=200
    frequency = weekly
  start_timestamp = '2020-09-22 00:00 PST'
    triggers on 80 percent do suspend
             on 100 percent do suspend_immediate;

alter warehouse compute_wh set resource_monitor = monitor_freq2;

alter warehouse pc_matillion_wh set resource_monitor = monitor_freq2;

In the next blog we will cover Assignment of Resource Monitors at Account level as well as at individual level.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

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