Reputation: 716
I am looking to monitor the credit usage for my snowflake account. For warehouse I can get the credit info from metering history where I can see which warehouse had how many credits . However I am not able to get the info for storage, For example I can see there is 12 tables whose size is huge like 100 plus terrabytes. I am getting that info from TABLE_STORAGE_METRICS. But I need to know how much credits are getting used by those table.
Is there any view or table in information schema which can shows how many credits are getting used for these table.
Upvotes: 2
Views: 1324
Reputation: 59175
To look at the average daily bytes used in the last days, you can use stage_storage_usage_history
:
select *
from table(information_schema.stage_storage_usage_history(dateadd('days',-10,current_date()), current_date()));
If you want to look at the detail from stages and databases:
select convert_timezone('UTC', usage_date) as usage_date
, database_name as object_name
, 'database' as object_type
, max(AVERAGE_DATABASE_BYTES) as database_bytes
, max(AVERAGE_FAILSAFE_BYTES) as failsafe_bytes
, 0 as stage_bytes
from snowflake.account_usage.database_storage_usage_history
where usage_date >= date_trunc('day', ('2021-12-01')::timestamp_ntz)
and usage_date < date_trunc('day', ('2021-12-05')::timestamp_ntz)
group by 1, 2, 3
union all select convert_timezone('UTC', usage_date) as usage_date
, 'Stages' as object_name
, 'stage' as object_type
, 0 as database_bytes
, 0 as failsafe_bytes
, max(AVERAGE_STAGE_BYTES) as stage_bytes
from snowflake.account_usage.stage_storage_usage_history
where usage_date >= date_trunc('day', ('2021-12-01')::timestamp_ntz)
and usage_date < date_trunc('day', ('2021-12-05')::timestamp_ntz)
group by 1, 2, 3;
As Greg says in a comment, you can transform these monthly average bytes into credits with a formula that will depend on the specifics of your account contract.
Upvotes: 2