ALTER RESOURCE MONITOR

Modifies the properties and triggers for an existing resource monitor. Use this command to increase or decrease the credit quota, change the scheduling information, or change/replace the triggers for a resource monitor.

See also:

CREATE RESOURCE MONITOR , DROP RESOURCE MONITOR , SHOW RESOURCE MONITORS , ALTER WAREHOUSE , ALTER ACCOUNT

语法

ALTER RESOURCE MONITOR [ IF EXISTS ] <name> [ SET { [ CREDIT_QUOTA = <num> ]
                                                    [ FREQUENCY = { MONTHLY | DAILY | WEEKLY | YEARLY | NEVER } ]
                                                    [ START_TIMESTAMP = { <timestamp> | IMMEDIATELY } ]
                                                    [ END_TIMESTAMP = <timestamp> ]
                                                    [ NOTIFY_USERS = ( <user_name> [ , <user_name> , ... ] ) ] } ]
                                            [ TRIGGERS triggerDefinition [ triggerDefinition ... ] ]

其中:

triggerDefinition ::=
   ON <threshold> PERCENT DO { SUSPEND | SUSPEND_IMMEDIATE | NOTIFY }

参数

name

指定要更改的资源监视器的标识符。如果标识符包含空格或特殊字符,则整个字符串必须放在双引号内。放在双引号内的标识符也区分大小写。

SET ...
CREDIT_QUOTA = num

指定每个频率间隔分配给资源监视器的 Credit。当分配给监视器的所有仓库的总使用量在当前频率间隔内达到此数字时,资源监视器被视为达到配额的 100%。

如果没有为资源监视器指定值,则监视器没有配额,并且永远不会在指定间隔内达到 100% 的使用量。

FREQUENCY = MONTHLY | DAILY | WEEKLY | YEARLY | NEVER

The frequency interval at which the credit usage resets to 0.

If you specify NEVER for the frequency, the credit usage for the warehouse does not reset.

START_TIMESTAMP = timestamp | IMMEDIATELY

资源监视器开始监控所分配仓库的 Credit 使用量的日期和时间。

If you specify IMMEDIATELY for the start timestamp, the current timestamp is used.

如果指定日期而不指定时间,则使用当前时间。

如果设置时间时未指定时区,则使用 UTC 作为默认时区。

END_TIMESTAMP = timestamp

资源监视器暂停分配的仓库的日期和时间。

NOTIFY_USERS = ( user_name [ , user_name , ... ] )

Specifies the list of users to receive email notifications on resource monitors. If a user identifier includes spaces or special characters or is case-sensitive, then the identifier must be enclosed in double quotes (e.g. “Mary Smith”). See Identifier requirements for details.

The user identifier, user_name, is the value of the name column from the output of SHOW USERS.

Each user listed must have a verified email address. For instructions on verifying email addresses in the web interface, see: Verify your email address.

Email notifications for non-administrator users do not supersede email notifications for administrators. Any account administrators that have enabled email notifications will continue to receive email notifications.

Note

  • The following limitations apply for non-administrator users:
    • Non-administrator users can only receive notifications for warehouse monitors.
    • Non-administrator users are notified by email but can’t see notifications in Snowsight.
    • Non-administrator users can’t create resource monitors.
    • Non-administrator users can’t assign other users to be notified.
TRIGGERS ... (aka actions)

为资源监视器指定一个或多个触发器。每个触发器定义包括:

  • ON threshold PERCENT (usage percentage; values larger than 100 are supported)
  • DO SUSPEND | SUSPEND_IMMEDIATE | NOTIFY (action to perform when the threshold is reached).

For more details, see CREATE RESOURCE MONITOR.

使用说明

  • If a SUSPEND or SUSPEND_IMMEDIATE trigger is active for a resource monitor and the trigger threshold has been reached for the specified frequency interval, thereby preventing all assigned warehouses from being started/resumed, you can use this command to either increase the credit quota above the trigger threshold or replace the trigger with a new trigger with a higher threshold.

当资源监视器的 Credit 配额或触发阈值增加后,就可以启动或恢复分配的仓库。

  • The TRIGGERS parameter is not additive; it removes all existing triggers for the resource monitor and replaces them with the specified triggers.

    As a result, to make additions to the existing triggers, you must specify the new triggers and replicate the existing triggers.

复制现有触发器会重新评估消耗量是否已达到触发百分比,如果达到触发百分比,则发送另一条通知。例如,假设通知的发送率为 70%,消耗量目前为 90%。如果您运行 ALTER 命令来指定 70% 的触发器,则会立即发送新的通知。

  • If frequency and start_timestamp parameters are set on a resource monitor, the day for the credit usage reset is calculated based on those parameters. The time the credit usage resets to 0 is 12:00 AM UTC regardless of the time specified in start_timestamp.
  • If you specify an end_timestamp, monitoring ends at that specified date and time and all assigned warehouses are suspended at that date and time even if the credit quota has not been reached.

出现这种情况时,系统会发出通知,说明资源监视器的配额已达到一定百分比,并触发了“立即暂停”操作。配额百分比反映了截至结束日期当前间隔内所使用的 Credit 数,可能不是您指定的阈值。

  • If there are non-administrator users in the notification list, the following notes apply:

    • If any user in the notification list does not have a verified email, the SQL statement fails.
    • If any user in the notification list changes their email address and does not verify the new email address, the notification silently fails.
    • The notification list is limited to a maximum number of 5 non-administrator users.
    • Account administrators can view the notification list of non-administrator users in the output of SHOW RESOURCE MONITORS in the notify_user column.
  • 关于元数据:

    Attention

    Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.

示例

Specify a new credit quota for the resource monitor limiter and replace the existing triggers for the monitor with a new set of triggers:

ALTER RESOURCE MONITOR limiter
  SET CREDIT_QUOTA=2000
  TRIGGERS ON 80 PERCENT DO NOTIFY
           ON 100 PERCENT DO SUSPEND_IMMEDIATE;

Alter a resource monitor to send notifications to three users when 80% of the credit quota is reached. In this example, the user_name for two of the users includes a space and is therefore enclosed in double quotes:

ALTER RESOURCE MONITOR limiter
  SET CREDIT_QUOTA = 2000
      NOTIFY_USERS = (JDOE, "Jane Smith", "John Doe")
  TRIGGERS ON 80 PERCENT DO NOTIFY
           ON 100 PERCENT DO SUSPEND_IMMEDIATE