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 notification is sent. You can configure the budget to send this notification to a list of email addresses, a queue provided by a cloud service (Amazon SNS, Azure Event Grid, or Google Cloud PubSub), or a webhook for a third-party system (for example, Slack, Microsoft Teams, or PagerDuty).
Account budget and custom budgets¶
The account budget monitors spending for all supported objects in the account.
You can also create a custom budget to monitor the spending limits for a specific group of supported objects.
For both types of budgets, you must set up the spending limit and specify how you want to receive notifications.
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. |
Apps . (Snowflake Native Apps) |
When you add a Snowflake Native App to a budget, all objects that consume credits and are created and owned by the app are added to the budget automatically. This includes warehouses and Snowpark Container Services compute pools that are owned by the app. Warehouses and compute pools that are shared are not tracked by the budget automatically, although you can add these manually. You cannot add objects created and owned by an app to a separate budget. You can add warehouses and compute pools that are shared to a separate budget. To determine if a warehouse or compute pool is owned by an app, check the following:
|
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. |
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. |
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. |
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 |
✔ |
||
DATA_QUALITY_MONITORING |
✔ |
✔ |
Table |
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 |
✔ |
✔ |
Compute pool |
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.
The following is an example of a notification sent through email:
To receive automatic alert notifications, you must do the following, as part of activating the account budget and creating a custom budget:
Set a spending limit for the budget.
Specify how you want to receive notifications about the budget.
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 notification integrations to use, 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, the notification integrations to use, the list of email addresses to receive notifications, the 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.
The following account-level parameters must be unset or set to the default value:
AUTOCOMMIT must be unset or set to TRUE.
If this parameter is set to FALSE, activating a budget might fail, or usage might not be tracked correctly.
TIMESTAMP_INPUT_FORMAT must be unset or set to AUTO.
If this parameter isn’t set to AUTO, usage might not be tracked correctly.
Before you activate budgets, check the values of these parameters by executing the SHOW PARAMETERS command:
SHOW PARAMETERS LIKE 'AUTOCOMMIT' IN ACCOUNT;
SHOW PARAMETERS LIKE 'TIMESTAMP_INPUT_FORMAT' IN ACCOUNT;
Note
You must set these parameters at the account level. Setting the parameters at a lower level (for example, at the session level) doesn’t have an effect on activating budgets or tracking usage.