Monitor credit usage with budgets¶
Budgets enables account-level monitoring and notification of Snowflake credit usage for a group of specific Snowflake objects.
Budgets overview¶
A budget defines a monthly spending limit on the compute costs for a Snowflake account or a custom group of Snowflake objects. When the spending limit is projected to be exceeded, a daily notification email is sent to the email addresses designated to receive budget notifications.
Account budget and custom budgets¶
The account budget monitors spending for all supported objects in the account. To get notifications for the account budget, set up the spending limit and specify email addresses to receive notifications.
You can also create a custom budget to monitor the spending limits for a specific group of supported objects. Like the account budget, you must set the spending limit and the notification email addresses in order to receive notification emails.
To start using budgets in Snowflake, activate the account budget.
Spending limit and time interval¶
The spending limit is expressed in Snowflake credits and is used for alerting and notifications purposes only. The spending limit is set for the time interval of one calendar month.
The time interval starts at 12:00AM UTC on the first day of the month and ends at 11:59PM UTC on the last day of the month. If a budget is created after the first day of the month, the first monitoring interval is the period until the last day of the current month, then is reset on the first of the following month.
If you activate your account budget after the first day of the month, data starting from the beginning of the month is backfilled and used to determine if you are going to exceed your spending limit for the month.
If you create a custom budget after the first day of the month, historical data for the month is not backfilled. Forecasting for future spend is based on the credit usage in the days only after the budget is enabled.
Note
If you create a custom budget after the first day of the month, you might exceed your budget for the first month. In a partial month, credit usage before the budget is created is not backfilled for custom budgets and might result in incorrect forecasting. Subsequent months will correctly forecast credit usage based on spending history.
Supported objects¶
Each object in the list of supported objects contributes to the spending limit for the account budget. For a custom budget, you can select a group of specific objects to monitor. When you add an object to a custom budget, the budget monitors all compute costs for the object, including background maintenance operations and serverless features. For example, if you add a table to a custom budget, and the table has automatic clustering enabled, the budget monitors credit usage for the background maintenance for automatic clustering.
A budget can monitor the following Snowflake objects:
Object |
Monitored costs |
---|---|
Alerts |
Serverless alerts are monitored by the account budget. To monitor the credit usage for an alert that executes using a user-managed warehouse, you must add the warehouse to the budget. For more information about the costs of alerts, see Understanding the costs of alerts. |
Compute pool |
Compute pool usage for Snowpark Container Services. For more information, see Compute pool cost. |
Databases |
When you add a database to a budget, all supported objects the database contains are also automatically added. The budget monitors credit usage for the following objects and serverless features:
|
Materialized views |
Background maintenance for the materialized view. For more information, see Materialized Views Cost. |
Pipes |
Resource consumption for loading data using Snowpipe. For more information, see Snowpipe costs. |
Tables |
Background maintenance operations for automatic clustering and search optimization if they are enabled on the table. |
Tasks |
Serverless tasks are monitored by a custom budget. To monitor the credit usage for a task that executes using a user-managed warehouse, you must add the warehouse to the budget. For more information, see Task costs. |
Schemas |
When you add a schema to a budget, all supported objects the schema contains are also automatically added. The budget monitors the credit usage for schema objects as described above. |
Warehouses |
Compute resources for query execution, web interface, and other features (see Virtual warehouse credit usage), serverless tasks, and cloud services compute. |
Supported serverless features¶
Budgets monitors the serverless feature credit usage for the supported objects contained in a budget. The following table lists serverless features and account and custom budget support for monitoring credit usage.
Note
Account budget support for serverless features depends on the availability of service types in the Account Usage METERING_HISTORY view view.
Serverless feature |
Account budget |
Custom budget |
Object |
---|---|---|---|
AI_SERVICES |
✔ |
||
AUTO_CLUSTERING |
✔ |
✔ |
Table |
COPY_FILES |
✔ |
||
HYBRID_TABLE_REQUESTS |
✔ |
||
MATERIALIZED_VIEW |
✔ |
✔ |
Materialized view |
PIPE |
✔ |
✔ |
Pipe |
QUERY_ACCELERATION |
✔ |
||
QUERY_ACCELERATION_READER |
✔ |
||
REPLICATION |
✔ |
✔ |
Database |
SEARCH_OPTIMIZATION |
✔ |
✔ |
Table |
SERVERLESS_ALERTS |
✔ |
✔ |
Alert |
SERVERLESS_TASK |
✔ |
✔ |
Task |
SNOWPARK_CONTAINER_SERVICES |
✔ |
✔ |
|
SNOWPIPE_STREAMING |
✔ |
✔ |
Table |
WAREHOUSE_METERING |
✔ |
✔ |
Warehouse |
WAREHOUSE_METERING_READER |
✔ |
✔ |
Warehouse |
Budgets notifications¶
A budget sends a daily alert notification when current spending is on track to exceed the spending limit based on time-series forecasting. Notifications begin when the projected spending is more than 10% above the spending limit. To receive automatic alert notifications, you must do the following:
Set a spending limit for the budget.
Set up email notifications for the budget.
The following is an example of a notification email:
You can disable email notifications for a budget by calling the SET_NOTIFICATION_MUTE_FLAG method.
Budgets roles and privileges¶
To enable a custom role in your account to work with budgets, you can grant the following roles and privileges.
Application roles to manage the account budget¶
You can grant the following application roles to a custom role in your account to monitor or manage the account budget:
Application Role |
Description |
---|---|
BUDGET_VIEWER |
Enables a role to view budget usage data and list the resources in the budget. |
BUDGET_ADMIN |
Enables a role to activate or deactivate the account budget and modify the properties of a budget including spending limit, the list of email addresses to receive notifications, and the mute notifications setting. |
In addition to the application role, there are other required privileges that must be granted to enable a custom role to monitor or manage the account budget. For more information, see Required roles and privileges.
Instance roles to manage custom budgets¶
Each custom budget has instance roles that you can grant to other roles to view or modify the budget:
Instance Role |
Description |
---|---|
VIEWER |
Enables a role to view budget usage data. |
ADMIN |
Enables a role to modify the properties of a budget including spending limit, list of email addresses to receive notifications, mute notifications setting, and the objects in the group. |
In addition to the instance role, there are other required privileges that must be granted to enable a custom role to create, monitor, or modify a custom budget. For more information, see Required roles and privileges.
Required roles and privileges¶
In addition to the application or instance roles, the following privileges must be granted to a custom role to monitor or manage budgets:
Privilege or role |
Budget type |
Create |
Manage |
Monitor |
Notes |
---|---|---|---|---|---|
USAGE_VIEWER |
Both |
✔ |
✔ |
✔ |
Grant the Snowflake database role USAGE_VIEWER to the custom role. |
USAGE |
Custom |
✔ |
✔ |
✔ |
Grant the USAGE privilege on the database that contains the custom budget. |
USAGE |
Custom |
✔ |
✔ |
✔ |
Grant the USAGE privilege on the schema that contains the custom budget. |
SNOWFLAKE.BUDGET_CREATOR |
Custom |
✔ |
Grant this database role to the custom role to enable it to create custom budgets. |
||
CREATE SNOWFLAKE.CORE.BUDGET |
Custom |
✔ |
Grant this privilege on the schema that will contain the custom budget. |
||
APPLYBUDGET |
Custom |
✔ |
Must be granted on each object to be added or removed from a custom budget. |
||
USAGE |
Custom |
✔ |
To add or remove schema objects from a custom budget, this privilege must be granted on the database and schema that contains the object. |
For more information and examples, see the following sections:
Limitations¶
The following are limitations for Budgets:
Instances of the BUDGET class can’t be replicated to target accounts.
An account can contain a maximum of 100 custom budgets.
Currently, Budgets does not support monitoring costs for Hybrid tables.