Skip to content

Daily

Get an email when a warehouse uses too many credits

Each morning you learn which warehouses used more than your limit in the last 24 hours.

Runs
Daily
Apps
Snowflake
AI
Not needed
Access
role with ACCOUNT_USAGE read

Send this to your assistant

Create a ClickRuntime automation: every morning at 7, check Snowflake warehouse credit usage for the last 24 hours and email me any warehouse that used more than 10 credits.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

Snowflake bills by the credit, and a warehouse that is left running or hit by a runaway query can burn through a month's budget in days. A new dashboard refreshes every minute, an analyst starts a large query on a Friday, a task loops, and nobody sees the cost until the invoice or the monthly review. By then the money is spent, and the finance team wants an explanation that nobody can give, because nobody was watching usage at the time.

Each day, ClickRuntime runs a SQL query against WAREHOUSE_METERING_HISTORY, sums credits per warehouse for the previous day, keeps those above your limit, such as 10 credits, and emails you the warehouse names and totals. If every warehouse stays within budget, no email is sent.

Data platform owners, finance partners and analysts who own a warehouse can use it as a basic budget guard.

What you get out of it

  • Overspend is caught the next morning

    A daily check turns a month-end surprise into a morning email, so a runaway warehouse is stopped after a day instead of after three weeks of expensive compute. The saving on a single runaway warehouse can easily exceed what months of monitoring would cost in effort.

  • Unexpected jobs are traced early

    Knowing which warehouse spiked narrows the search to a handful of queries and users, so the cause can be found while people still remember what they ran. Query history for that day is still fresh and has not yet aged out of the interface.

  • Budgets become manageable

    A per-warehouse daily limit makes a monthly credit budget concrete. Teams see how close they are running, and can make decisions before the invoice arrives. Planning the next quarter's spend then rests on real daily patterns.

  • Quiet days produce no noise

    Because mail is sent only when a warehouse crosses the limit, the alert is a signal instead of a daily report that people learn to ignore. People keep reading it because it only appears when action is needed.

  • Finance conversations are better informed

    With dated alerts showing which warehouse used how many credits on which day, a finance partner can ask specific questions rather than just asking why the bill was high. Cost discussions then move from blame to concrete fixes.

How it works

What happens, step by step

  1. Every morning, ClickRuntime asks Snowflake how many credits each warehouse used in the last 24 hours.

  2. It keeps only the warehouses that went over the limit you set.

  3. If any did, you get an email listing each one with the credits it used.

Before it runs live

  • Connect Snowflake

What you get

RunsDaily
Get an email when a warehouse uses too many creditstoday, 9:00Succeeded
Email · Snowflake warehouses over 10 creditsTRANSFORM_WH: 23.4 credits in the last 24h BI_WH: 11.2 credits in the last 24h

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Snowflake steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
daily_credit_usage_alert.pyexample
from clickruntime import on_trigger, credentials, http, notify

ACCOUNT = "myorg-myaccount"
WAREHOUSE = "ADMIN_WH"
LIMIT = 10

def sql(statement):
    resp = http.post(f"https://{ACCOUNT}.snowflakecomputing.com/api/v2/statements",
                     headers={"Authorization": f"Bearer {credentials.secret('SNOWFLAKE_PAT')}",
                              "X-Snowflake-Authorization-Token-Type": "PROGRAMMATIC_ACCESS_TOKEN"},
                     json={"statement": statement, "warehouse": WAREHOUSE, "timeout": 60})
    resp.raise_for_status()
    return resp.json()["data"]

@on_trigger
def run(event):
    rows = sql("SELECT warehouse_name, SUM(credits_used) FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY "
               "WHERE start_time >= DATEADD(hour, -24, CURRENT_TIMESTAMP()) GROUP BY 1 ORDER BY 2 DESC")
    over = [(name, float(credits)) for name, credits in rows if float(credits) > LIMIT]
    if over:
        notify.email_me("Snowflake warehouses over 10 credits",
                        "\n".join(f"{n}: {c:.1f} credits in the last 24h" for n, c in over))
    return {"over": len(over)}

FAQ

Common questions

Where does the usage data come from?
It reads the WAREHOUSE_METERING_HISTORY view in the ACCOUNT_USAGE schema, which Snowflake populates with credits per warehouse by hour. That data can lag by a few hours, so yesterday's totals are the reliable ones.
What Snowflake permissions are needed?
The role used needs access to the SNOWFLAKE database's ACCOUNT_USAGE schema, often granted through the USAGE_VIEWER or a custom role. A dedicated read-only role is a sensible choice for this kind of check.
Can the limit differ per warehouse?
Yes. A large ETL warehouse may normally use 40 credits while a reporting one uses 3. Set a limit for each, and the email only lists the ones that exceed their own threshold. Different limits make the alerts sensible for each workload.
What permissions does it need?
role with ACCOUNT_USAGE read. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Get an email when a warehouse uses too many credits” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.