<budget_name>!GET_SERVICE_TYPE_USAGE

View the credit usage for a budget by service type.

See also:

<budget_name>!GET_SPENDING_HISTORY

Syntax

<budget_name>!GET_SERVICE_TYPE_USAGE( SERVICE_TYPE => '<service_type>' ,
                                      TIME_DEPART => '<time_interval>' ,
                                      USER_TIMEZONE => '<timezone>' ,
                                      TIME_LOWER_BOUND => <constant_expr> ,
                                      TIME_UPPER_BOUND => <constant_expr>
                                    )
Copy

Arguments

SERVICE_TYPE => service_type

The service type used to limit results.

Valid values:

Type of service that is consuming credits, which can be one of the following:

  • AUTO_CLUSTERING

  • DATA_QUALITY_MONITORING

  • HYBRID_TABLE_REQUESTS

  • MATERIALIZED_VIEW

  • PIPE

  • QUERY_ACCELERATION

  • SEARCH_OPTIMIZATION

  • SERVERLESS_ALERTS

  • SERVERLESS_TASK

  • SNOWPIPE_STREAMING

  • WAREHOUSE_METERING

  • WAREHOUSE_METERING_READER

TIME_DEPART => time_interval

Time interval used to delineate usage records. Each row displays service usage by the specified time interval.

Valid values:

  • HOUR, hour

  • DAY, day

  • WEEK, week

USER_TIMEZONE => timezone

String specifying the user’s timezone. Budget metering is based on the UTC timezone.

TIME_LOWER_BOUND => constant_expr

The start of the time range during which the spending occurred.

TIME_UPPER_BOUND => constant_expr

The end of the time range during which the spending occurred.

Returns

The function returns the following columns:

Column Name

Data Type

Description

START_TIME

TIMESTAMP_TZ

Date and time the usage occurred.

ENTITY_ID

NUMBER

Internal identifier for the object in the budget.

NAME

VARCHAR

Name of the metered object.

CREDITS_USED

FLOAT

Number of credits used. This is the sum of CREDITS_COMPUTE and CREDITS_CLOUD.

CREDITS_COMPUTE

FLOAT

Number of compute credits used.

CREDITS_CLOUD

FLOAT

Number of cloud service credits used.

Access control requirements

  • The following minimum privileges and roles are required to view results for custom budgets:

  • The following role is required to view results for the account budget:

For more information, see Budgets roles and privileges.

Usage notes

  • For timezone, you can specify a time zone name (https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab) or a link name (https://data.iana.org/time-zones/tzdb-2021a/backward) from release 2021a of the IANA Time Zone Database (https://www.iana.org/time-zones) (e.g. America/Los_Angeles, Europe/London, UTC, Etc/GMT, etc.).

    Note

    • Time zone names are case-sensitive and must be enclosed in single quotes (e.g. 'UTC').

    • Snowflake does not support the majority of timezone abbreviations (link removed) (e.g. PDT, EST, etc.) because a given abbreviation might refer to one of several different time zones. For example, CST might refer to Central Standard Time in North America (UTC-6), Cuba Standard Time (UTC-5), and China Standard Time (UTC+8).

  • Calling this method does not return the object. Because of this, you can’t use method chaining to call another method on the return value of this method. Instead, call each method in a separate SQL statement.

Examples

View the daily credits spent for each warehouse in the past week for the account budget:

CALL snowflake.local.account_root_budget!GET_SERVICE_TYPE_USAGE(
   SERVICE_TYPE => 'WAREHOUSE_METERING',
   TIME_DEPART => 'day',
   USER_TIMEZONE => 'UTC',
   TIME_LOWER_BOUND => dateadd('day', -7, current_timestamp()),
   TIME_UPPER_BOUND => current_timestamp()
);
Copy

Error messages

To troubleshoot issues that can occur when you call this method, see You can’t successfully call the GET_SERVICE_TYPE_USAGE method.

Language: English