Troubleshoot budgets

This topic explains how to monitor budgets for problems and provides solutions to common issues.

Using an event table to monitor budgets

You can use an event table to collect telemetry data related to budgets. After Snowflake starts collecting the data in the event table, you can query the table, create a stream to track changes, or set alerts to send notifications when certain events occur.

If you don’t want to collect telemetry data for budgets, you must set the ENABLE_BUDGET_EVENT_LOGGING account parameter to FALSE to turn it off.

Understanding the events

The following table describes the values in the event table that correspond to budget events so you can focus on the appropriate events. For detailed information about the structure of an event table, see Event table columns.

Event table columnFieldValueDescription
resource_attributessnow.cost.budget.idbudget_idUnique ID of the budget instance.
snow.cost.budget.namebudget_nameFully qualified name of the budget instance.
scopenamesnow.cost.budgetConstant identifier for all budget telemetry events.
record_typen/aEVENTIndicates a budget log event.
recordnameevent_name

Descriptive event name. Possible values include the following:

  • BUDGET_UNVERIFIED_RECIPIENTS — Occurs when email addresses are not in the integration’s allowed recipients list or there are email addresses that are not verified.
  • BUDGET_INVALID_INTEGRATION — Occurs when a notification integration doesn’t exist or the user lacks access to it.
severity_textINFO, WARNING, or ERRORSeverity level of budget event.
valuemessagemessageDescriptive event message, often including contextual details such as an integration name or operation.

Use the following examples to better understand how to identify budget events in an event table.

Query: Find all events related to the propagation of all budgets within the account
SELECT
    TIMESTAMP,
    RESOURCE_ATTRIBUTES,
    SCOPE,
    RECORD_TYPE,
    RECORD,
    VALUE
  FROM SNOWFLAKE.TELEMETRY.EVENTS
  WHERE
    RECORD_TYPE = 'EVENT' AND
    SCOPE['name'] = 'snow.cost.budget';
Query: Find all events related to a specific budget (for example, MY_DB.SCH1.MY_BUDGET)
SELECT
    TIMESTAMP,
    RESOURCE_ATTRIBUTES,
    SCOPE,
    RECORD_TYPE,
    RECORD,
    VALUE
  FROM SNOWFLAKE.TELEMETRY.EVENTS
  WHERE
    RECORD_TYPE = 'EVENT' AND
    SCOPE['name'] = 'snow.cost.budget'
    AND RESOURCE_ATTRIBUTES['snow.cost.budget.name'] ILIKE 'MY_DB.SCH1.MY_BUDGET';

Troubleshooting specific problems

The following scenarios can help you troubleshoot issues that can occur when creating or editing budgets:

You can’t activate the account budget

There are multiple reasons you might be unable to activate your account budget:

Error
Unknown user-defined function SNOWFLAKE.LOCAL.ACTIVATE
CauseIf your Snowflake account is new, the account budget is not yet available in your account.
SolutionWait for the account budget to be available in your newly created account. You can activate it after it becomes available.
Error
FAILURE: Uncaught exception of type 'BUDGET_ALREADY_ACTIVATED' on line X at position X
CauseThe account budget has already been activated.
Solution

You can call the <budget_name>!GET_CONFIG method to view the activation timestamp:

CALL SNOWFLAKE.LOCAL.ACCOUNT_ROOT_BUDGET!GET_CONFIG();
Error
-20000 (P0001): Uncaught exception of type 'NO_PERMISSION_TO_ACTIVATE_BUDGET' on line X at position X
CauseYour account does not yet support the Budgets feature.
SolutionThe Budgets feature is not available for accounts in Gov regions. Support for Gov regions will be available in a future release.

You can’t create a custom budget

There are multiple reasons you might be unable to create a custom budget.

Error
FAILURE: SQL access control error: Insufficient privileges to operate on class 'BUDGET'
CauseThe role you are using does not have the privileges required to create custom budgets.
SolutionUse a role with the required privileges. See Create a custom role to create budgets.
Error
FAILURE: Uncaught exception of type 'STATEMENT_ERROR' on line 0 at position -1 :
Uncaught exception of type 'UNSUPPORTED_BUDGET_TYPE' on line X at position X
CauseYou pass arguments to the constructor method to create a budget.
SolutionSee CREATE BUDGET and edit your create statement.

You can’t activate a custom budget

Error
FAILURE: Uncaught exception of type 'STATEMENT_ERROR' on line 0 at position -1 :
Uncaught exception of type 'UNSUPPORTED_BUDGET_TYPE' on line X at position X
CauseYou tried to call the ACTIVATE method on a custom budget.
Solution

The ACTIVATE method is only available on the account budget. After you have created a custom budget, use the <budget_name>!SET_SPENDING_LIMIT and <budget_name>!SET_EMAIL_NOTIFICATIONS methods to configure the budget and start receiving notification emails.

You can’t call methods on the account budget

There are multiple reasons why calling a method on the account budget might fail.

Error
-20000 (P0001): Uncaught exception of type 'FUNCTION_NOT_SUPPORTED_FOR_ACCOUNT_ROOT_BUDGET' on line 11 at position 18
Cause

You tried to call any of the following methods on the account budget:

Solution

These methods are not available on the account budget. The account budget monitors all supported objects in the account and objects cannot be added or removed. For more information, see Account budget and custom budgets.

Error
-20000 (P0001): Uncaught exception of type 'ACCOUNT_ROOT_BUDGET_NOT_ACTIVATED' on line X at position X
CauseYou tried to call a method on the account budget before the account budget is activated.
SolutionActivate the account budget.

You can’t add or remove objects from a custom budget

To successfully add or remove an object from a custom budget, the role used to call the method must have the required privileges and role.

Error
002141 (42601): SQL compilation error:
Unknown user-defined function <budget_db>.<budget_schema>.<budget_name>!ADD_RESOURCE
Cause

The role you used to call the instance method does not have the required privileges to add (or remove) objects from the budget.

Solution

Grant the required instance role and privileges to the role used to call the method. For more information, see Create a custom role to monitor a custom budget.

Error
002003 (02000): SQL compilation error:
<object_type> '<object_name>' does not exist or not authorized.
CauseYou tried to add an object to a custom budget but the role you used to call the method doesn’t have the required privileges.
Solution

To add (or remove) an object from a budget, the role used to call the method must have the APPLYBUDGET privilege on the object. If the parent object is a database or schema, you must also have the USAGE privilege on the database and schema that contain the object.

For more information, see the list of required object privileges.

Error
Uncaught exception of type 'EXPRESSION_ERROR' on line 10 at position 21 :
Privilege 'APPLYBUDGET' is not authorized on the reference object.
CauseYou tried to create a reference for an object without specifying the PRIVILEGE parameter in the SYSTEM$REFERENCE statement.
SolutionCreate the reference with the APPLYBUDGET privilege on the object.
Error
505001 (55000): Uncaught exception of type 'EXPRESSION_ERROR' on line 10
at position 21 : Specified object does not exist or not authorized for
the reference.
Cause

There are multiple causes for this error message:

  • You tried to add the SNOWFLAKE database to a custom budget with an inline SYSTEM$REFERENCE statement.
  • You don’t have the required privileges on the object to create a reference for it. The valid reference is required to add the object to a budget.
Solution

You can’t set email notifications for a budget

The following scenarios can help you troubleshoot common issues when calling the <budget_name>!SET_EMAIL_NOTIFICATIONS method.

Error
Unknown user-defined function <database_name>.<schema_name>.<budget_name>.SET_EMAIL_NOTIFICATIONS
CauseThe role you used to set the email notifications for a custom budget does not have the ADMIN instance role.
SolutionUse a role with the required privileges and roles. See the Access control requirements for SET_EMAIL_NOTIFICATIONS.
Error
Integration '<INTEG_NAME>' does not exist or not authorized.
CauseThe notification integration does not exist.
SolutionUse a valid notification integration. For more information, see Create an email notification integration. Include the email addresses for budgets notifications in the ALLOWED_RECIPIENTS list.
Error
FAILURE: Uncaught exception of type 'EXPRESSION_ERROR' on line 16 at position 34 : Following email address(es) are not
allowed by the email integration <INTEGRATION_NAME>: [<email>]
CauseThe email addresses are not included in the notification integration.
Solution

Add the email addresses to the notification integration, or use a notification integration that includes all the email addresses in the ALLOWED_RECIPIENTS list.

Error
Email recipients in the given list at indexes [<index_list>] are not allowed. Either these email addresses are not yet validated
or do not belong to any user in the current account.
CauseSome or all of the email addresses you tried to add are not validated.
SolutionSee Verify the email addresses of the email notification recipients.

You can’t successfully call the GET_SERVICE_TYPE_USAGE method

The following scenarios can help you troubleshoot common issues when calling the <budget_name>!GET_SERVICE_TYPE_USAGE method.

Error
001044 (42P13): SQL compilation error: error line 0 at position -1 Invalid argument types for function 'GET_SERVICE_TYPE_USAGE':
(VARCHAR(X), VARCHAR(X), VARCHAR(X), VARCHAR(X))
CauseYou called the method with invalid arguments or the wrong number of arguments.
SolutionCheck that the arguments you use to call the method are valid and that you’ve included all required arguments.
Error
002151 (22023): Uncaught exception of type 'STATEMENT_ERROR' on line 16 at position 23 : SQL compilation error:
[:TIME_DEPART] is not a valid date/time component for function DATE_TRUNC.
CauseThe TIME_DEPART argument is an invalid string.
Solution

Use one of the valid values listed for the TIME_DEPART argument in the reference topic.

Error
100094 (22000): Uncaught exception of type 'STATEMENT_ERROR' on line 16 at position 23 : Unknown timezone: '<invalid_timezone>'
CauseThe USER_TIMEZONE argument is an invalid string.
Solution

Use a valid timezone string. For more information, see the usage notes for GET_SERVICE_TYPE_USAGE.

The Budgets feature is not available for your account

Errors
FAILURE: SQL compilation error: Class 'SNOWFLAKE.CORE.BUDGET' does not exist or not authorized.
000002 (0A000): Uncaught exception of type 'STATEMENT_ERROR' on line 0 at position -1 : Unsupported feature 'TOK_RESOURCE_GROUP'.
CauseYour account does not yet support the Budgets feature.
SolutionThe Budgets feature is not available for accounts in Gov regions. Support for Gov regions will be available in a future release.