Resource Monitor
Configuration can be provided to Snowflake Object Lifecycle Engine for the following operation with resource monitors:
- Manage Lifecycle of new and existing Resource Monitor
- Manage Lifecycle of cloned Resource Monitor
- Manage Grants of Resource Monitor
#
Supported ParametersThe engine supports the parameters listed below.
- CREDIT_QUOTA: The number of credits allocated to the resource monitor per frequency interval. When total usage for all warehouses assigned to the monitor reaches this number for the current frequency interval, the resource monitor is considered to be at 100% of quota.
- Configuration key:
credit_quota
- Data Type: Integer
- Configuration key:
- FREQUENCY: The frequency interval at which the credit usage resets to 0.
- Configuration key:
frequency
- Data Type: String
- Possible Values:
- DAILY
- WEEKLY
- MONTHLY
- YEARLY
- NEVER
- Configuration key:
- START_TIMESTAMP: The date and time when the resource monitor starts monitoring credit usage for the assigned warehouses.
- Configuration key:
start_timestamp
- Data Type: String. Must be a valid Date or timestamp
See START_TIMESTAMP Usage for Resource Monitor
- Configuration key:
- END_TIMESTAMP: The date and time when the resource monitor suspends the assigned warehouses.
- Configuration key:
end_timestamp
- Data Type: String. Must be a valid Date or timestamp
See END_TIMESTAMP Usage for Resource Monitor
- Configuration key:
- NOTIFY_TRIGGERS: A list of percentage thresholds at which to send an alert to subscribed users.
- Configuration key:
notify_triggers
- Data Type: Array/List of Integers
- Configuration key:
- SUSPEND_TRIGGERS: A list of percentage thresholds at which to suspend all warehouses.
- Configuration key:
suspend_triggers
- Data Type: Array/List of Integers
- Configuration key:
- SUSPEND_IMMEDIATE_TRIGGERS: A list of percentage thresholds at which to immediately suspend all warehouses.
- Configuration key:
suspend_immediate_triggers
- Data Type: Array/List of Integers
- Configuration key:
- NAMESPACING: Specify whether Prefix or Suffix or both are to be added to Resource Monitor Name.
- Configuration key:
namespacing
- Data Type: String
- Possible Values:
none
prefix
suffix
both
(Default)
- Configuration key:
- ENVIRONMENT: Specify the environment in which the Resource Monitor is managed. Regex can be provided as well.
- Configuration key:
environment
- Data Type: string
- Configuration key:
- MANAGE_MODE: Configures what properties to manage for the Resource Monitor.
- Configuration key:
manage_mode
- Data Type: string
- Possible Values:
none
grants
all
(Default)
- Configuration key:
- GRANTS: List of Privileges and Roles to which privileges are granted to on the current Resource Monitor.
- Configuration key:
grants
- Data Type: Map
- Configuration key:
#
TimestampAs per Snowflake Docs, the START_TIMESTAMP
and END_TIMESTAMP
parameters support valid timestamps as values.
When setting the parameter to any valid timestamp that has time mentioned in it as well, leads to an SQL compilation error with message Invalid date/time format string
This error occurs while creating as well as updating a Resource Monitor.
To bypass this error, a valid Date must be provided when creating or updating the Resource Monitor.
This Date is converted to its timestamp equivalent after creation or update.
This leads to another issue, when managing the resource with Snowflake Object Lifecycle Engine engine.
Each time a pipeline is run, the engine would compare the two values.
The configuration defines a Date while the local state has a timestamp present in it.
As the values are not similar(Date is not equal to timestamp although their values are equivalent), the engine determines that the resource monitor has to be updated.
This leads to a replacement of the resource monitor(START_TIMESTAMP
and END_TIMESTAMP
lead to replacement of the object), each-time a pipeline is run.
This replacement could be avoided, if after creation or update of the resource monitor, the values of START_TIMESTAMP
and END_TIMESTAMP
are set to timestamp.
#
Basic syntaxresource_monitors: <resource-monitor-name>: <configuration-key>: <value> grants: <privilege>: - <role-name> - <role-name>
#
ExampleInitial Configuration
resource_monitors: RESOURCE_MONITOR_1: frequency: "YEARLY" start_timestamp: "2021-04-15" end_timestamp: "2022-04-15" notify_triggers: - 40 suspend_triggers: - 50 suspend_immediate_triggers: - 90
Configuration Update after Creation/Update
resource_monitors: RESOURCE_MONITOR_1: frequency: "YEARLY" start_timestamp: "2021-04-15T00:00:00Z" end_timestamp: "2022-04-15T00:00:00Z" notify_triggers: - 40 suspend_triggers: - 50 suspend_immediate_triggers: - 90
If a new branch is created from this,
START_TIMESTAMP
andEND_TIMESTAMP
have to be set back to Dates
#
Supported Resource Monitor Grants to RolesFollowing is the list of Privileges Grant to Roles that can be specified in the database definition
- ALL PRIVILEGES
- MODIFY
- MONITOR
#
Examplesresource_monitors: RESOURCE_MONITOR_1: credit_quota: 1000 frequency: "YEARLY" start_timestamp: "2021-04-15" end_timestamp: "2022-04-15" notify_triggers: - 40 suspend_triggers: - 50 suspend_immediate_triggers: - 90 grants: MONITOR: - DEV_ROLE