Skip to content

Connecting Snowflake to CostReveal, setup guide

The CostReveal team, , 6 minute read

Snowflake bills in credits converted to your contract's currency, account by account, and a warehouse running all night is easy to miss until the invoice arrives. This guide covers how CostReveal reads what Snowflake charged your organization, how each day's warehouse charge is divided among warehouses, what the setup statements create, how tags explain spend, how fresh the figures are, and what reading costs you in Snowflake.

What the Snowflake connection reads

CostReveal reads three views from your Snowflake organization, and nothing else:

  • Charges, from SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY: each account's charge each UTC day, in your contract's currency, by service type, such as warehouses, storage, cloud services and serverless tasks, with adjustments and credits as they land.
  • Warehouse metering, from WAREHOUSE_METERING_HISTORY: the compute credits each warehouse used.
  • Tags, from TAG_REFERENCES, on accounts and warehouses.

It does not read query history, query text or your data. Spend is recorded by account, service type and warehouse.

How warehouse charges are divided

An account's warehouse compute on a day is charged at one rate. So CostReveal divides each day's warehouse charge among that account's warehouses by the credits each used, exactly, with the parts adding up to the charge. The result is a figure per warehouse, in currency, that agrees with what Snowflake billed.

What you need

  • Access to your organization account, or an account with ORGADMIN enabled, to run the setup statements.
  • An owner or admin role in CostReveal.

Step by step setup

1. Start the connection

In CostReveal, go to Connections and choose Connect Snowflake. CostReveal makes a key for the connection and shows its public half inside the setup statements. The private half never leaves CostReveal.

2. Run the setup statements

Run the statements CostReveal shows, as one block, in your organization account or an account with ORGADMIN enabled. They create:

  • A role holding the organization's billing, usage and governance viewer roles, which is all CostReveal needs to read the three views.
  • An extra small warehouse that suspends itself after a minute, for CostReveal's queries.
  • A service user that signs in only with CostReveal's key, with no password.

3. Verify and connect

Enter the account identifier, such as myorg-myaccount. The user, role and warehouse are filled in with the names the statements create. Choose Verify and connect. Only the format is checked as you type. When you verify, CostReveal signs in and reads this month's charges before saving anything. If something is missing, it says which: a key not set on the user, a role without the viewer roles or the warehouse, or an account without the organization's usage.

No password or secret of yours changes hands. Unsetting the key on the user, or dropping the user, ends access at once.

Freshness, history and what reading costs

Snowflake states each day's charges up to 72 hours later, and adjusts a month until it closes. CostReveal reads every six hours, and reads the current and previous month each time, so late credits and adjustments are recorded. The first read also brings in the twelve months before the current one, as far as Snowflake holds them. Where Snowflake holds no older months, Connections says how far back it reached, and each read asks again.

Each month is summarized first, and read in full only when its charges have changed. Reading takes a few seconds a day of the extra small warehouse, and Snowflake charges you for that warehouse time, as for any warehouse.

Connection states

Under Connections, the connection is always in one of four states:

  • Setup not finished: the details have not been verified yet.
  • Waiting for first data: everything was verified, and the first read is due.
  • Connected: the charges were read and the latest read succeeded.
  • Needs attention: the latest read failed, for example because the key was unset on the user. Everything already read is kept.

How Snowflake spend is explained

  • Direct: the service, such as warehouses or storage, which Snowflake reports itself.
  • Inferred: the team, feature and customer, when a tag on the account or warehouse names them, read with the project's tag keys. A warehouse tagged TEAM = 'payments' is the payments team's.
  • Allocated: a share of a cost an allocation rule divides, by fixed percentages, evenly, or in proportion to what each owner's tags already explain.
  • Unknown: spend no tag or rule explains. It is shown as unknown, never spread across teams.

Tags need Snowflake's Enterprise Edition. Without them, everything else is read the same, and allocation rules can still assign an account or a warehouse to a team: a rule on the account or the resource names its owner, and the rule is shown with the figure.

A practical layout

Snowflake costs are easiest to explain when each team or workload has its own warehouse. Then a tag on the warehouse, or a rule naming its owner, explains all its compute, and the per warehouse division keeps the figures exact. Shared warehouses can be split with an allocation rule.

How figures are checked

Every amount is recorded as Snowflake states it, in currency. A change Snowflake makes to a month already read, such as a late credit, is recorded as a correction that keeps what was said before, and attribution runs again. Attribution on every dimension must then add up exactly to the ledger.

Snowflake states charges in currency in this one view, so there is no second source to compare the total against. Home says the figures tie out, with no second source named, rather than implying a check that did not happen.

Getting more of Snowflake spend explained

  1. Give each team or workload its own warehouse where you can.
  2. Tag warehouses and accounts with a key the project reads, such as team or owner, on Enterprise Edition.
  3. Write rules for what tags cannot reach, such as a whole account that belongs to one team, or a shared warehouse to split.
  4. Look at Explore by resource and service to find warehouses with no owner.

Troubleshooting

  • Verify says the key is not set. Run the statement that sets CostReveal's public key on the service user, as shown in setup.
  • Verify says the role lacks access. Check the role holds the organization's billing, usage and governance viewer roles, and can use the warehouse.
  • Verify says the account has no organization usage. Run the statements in the organization account, or an account with ORGADMIN enabled.
  • A recent day looks low. Snowflake states charges up to 72 hours later; the figures fill in as it does.

Removing the connection

Removing the connection under Connections deletes every figure it brought in from the project. Drop the service user, role and warehouse in Snowflake too. To stop reading without removing anything, unset the key on the user or drop the user: CostReveal keeps every figure already read and tells you new data has stopped.

Frequently asked questions

Does CostReveal read my queries or data? No. It reads three views: daily charges in currency, warehouse metering, and tag references. It never reads query history, query text or tables.

How are warehouse costs worked out? An account's warehouse charge for a day is divided among its warehouses by the credits each used, exactly, so the parts add up to what Snowflake billed.

What does reading cost in Snowflake? A few seconds a day of an extra small warehouse that suspends itself after a minute, billed by Snowflake like any warehouse.

Do I need Enterprise Edition? Only for tags. Without it, everything else is read the same, and allocation rules can assign accounts and warehouses to owners.

How do I rotate the key? Remove the connection and connect again: CostReveal makes a new key for the new connection, and you set its public half on the user. Removing the connection deletes its figures; the new one reads the current month and the twelve before it again.

How fresh are the figures? CostReveal reads every six hours. Snowflake states each day's charges up to 72 hours later and adjusts a month until it closes, and those changes are recorded as they land.

Keep reading