How can we find the balance of credits in snowflake?

Viewed 590

Is there any way, we can figure out how many remaining credits we have in snowflake?

Thanks.

3 Answers

It is possible to find credit consumption is classic Web UI and New Web Interface:

Viewing Account-level Credit and Storage Usage in the Web Interface

The key point are privileges required to see this kind of data:

Only account administrators (i.e. users with the ACCOUNTADMIN role) or a role with the global MONITOR USAGE privilege can access the billing and usage information in the classic web interface.

Only account administrators can access the billing and usage information in the new web interface.

This can also be done in SQL. In fact, this is what happens behind the scenes when you use the web interface. Provided that you have sufficient privileges (ie, users users with the ACCOUNTADMIN role or a role with the global MONITOR USAGE privilege), you can query the warehouse_metering_history Account Usage view. For example, credits used by each warehouse in your account (month-to-date):

USE "SNOWFLAKE"."ACCOUNT_USAGE";

SELECT warehouse_name,
       SUM(credits_used) AS total_credits_used
FROM   warehouse_metering_history
WHERE  start_time >= Date_trunc(month, current_date)
GROUP  BY warehouse_name
ORDER  BY total_credits_used;

Or, credits used over time by each warehouse in your account (month-to-date):

SELECT start_time :: DATE AS usage_date,
       warehouse_name,
       SUM(credits_used)  AS total_credits_used
FROM   warehouse_metering_history
WHERE  start_time >= Date_trunc(month, current_date)
GROUP  BY usage_date,warehouse_name
ORDER  BY warehouse_name, usage_date; 

https://docs.snowflake.com/en/sql-reference/account-usage.html#account-usage-views

Related