Documentation
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Daily Limits

The DAILY_LIMITS Pre-hook works in concert with the Sundeck Native App to implement granular cost control, allowing daily credit consumption limits to be set and enforced at the USER or ROLE level.

To use this hook, define the maximum number of Snowflake credits that a user or role may consume in one day (midnight to midnight). When a user/role has exceeded their daily configured limit, additional queries submitted during that day are rejected by Sundeck before being sent to Snowflake. Available credits are reset at midnight, or can be increased for a particular user/role by modifying the hook’s configuration.

This hook requires that Snowflake Native App is linked to your Sundeck account before this hook can be effective.

The number of credits used by a Snowflake user/role is defined as the sum over all queries which have completed in the current day (00:00 to 23:59) in the default TIMEZONE parameter configured for your Snowflake account. The number of credits used include Snowflake Cloud Services credits when applicable. Credits used by tasks executed on Snowflake Serverless Warehouses are not assigned to any user or role.

You can use the Hook’s Condition to apply granular rules applied to specific users/roles. You can also add multiple instances of this hook to a single flow to apply different limits to sets of users/roles. See the below examples for more details.

Configuration Syntax

DAILY_LIMITS {
    'limitBy': <limitBy>,
    'maxCredits': <maxCredits>
}

Arguments

<limitBy>
The entity to be targeted by this hook. Accepted values are ‘User’ and ‘Role’.
  • User set a limit on each Snowflake users.
  • Role sets a limit on each Snowflake role.
<maxCredits>
The positive number of Snowflake credits allowed to be used by the entity specified by <limitBy> in the current day.

Examples

Limit all Snowflake users to a maximum of 10 credits per day.

CREATE SUNDECK FLOW ALL_USER_LIMITS
    PRE HOOK "Limit all users to 10 credits per user per day"
    DAILY_LIMITS {'limitBy': 'User', 'maxCredits': 10}

Limit all Snowflake roles except ACCOUNTADMIN to a maximum of 30 credits per day.

CREATE SUNDECK FLOW NON_ADMIN_ROLE_LIMITS
    PRE HOOK "Limit non-Admin roles to 30 credits per role per day"
    IF ROLE <> "ACCOUNTADMIN"
    THEN DAILY_LIMITS {'limitBy': 'Role', 'maxCredits': 30}

Limit a subset of Snowflake users to a very small number of credits/day.

CREATE SUNDECK FLOW LIMITED_USERS
    PRE HOOK "Limit inexperienced users to 2 credits per day"
    IF USER = "JuniorDev" OR USER = "Intern"
    THEN DAILY_LIMITS {'limitBy': 'User', 'maxCredits': 2}

Limitations

  • Snowflake Native App must be linked to your Sundeck account to use this hook. If Snowflake Native App is not linked to your Sundeck account, all users/roles will be treated as if they have used no credits.
  • The COST_CONTROL_MONITORING task in the Sundeck Native App must not be suspended (it is running by default).
  • Queries that are executed on Snowflake serverless warehouses are excluded from the credit consumption calculations.
  • A maximum of 10,000 (ten thousand) queries are considered per two hours. For Snowflake accounts that execute more than 10,000 queries over the span of two hours, consumed credits may be under-reported.