Warehouse Credit Spike — Last 24h
Warehouse spend exceeds the 30-day daily max by more than 30%.
Why monitor
- Compares today's credits per warehouse against a 30-day rolling baseline — alerts only when spend is genuinely anomalous, not just on normally busy days.
- Uses INFORMATION_SCHEMA for real-time data — no 45-minute ACCOUNT_USAGE lag, catches runaway warehouses within the hour.
- Per-warehouse segmentation isolates which workload (ETL, BI, ad-hoc) is responsible for the spike.
SELECT * FROM (
WITH
"main_metric" AS (
SELECT
warehouse_name,
SUM(credits_used) AS "METRIC_VALUE",
SUM(credits_used_compute) AS compute_credits,
SUM(credits_used_cloud_services) AS cloud_credits
FROM TABLE(information_schema.warehouse_metering_history(
dateadd('hours', -25, current_timestamp()),
dateadd('hours', -1, current_timestamp())
))
GROUP BY warehouse_name
),
"Compared Trend 1_time_windows" AS (
SELECT
DATEADD('day', -SEQ4() - 1, current_timestamp()) AS "WINDOW_END",
DATEADD('hours', -24, DATEADD('day', -SEQ4() - 1,
current_timestamp())) AS "WINDOW_START"
FROM TABLE(GENERATOR(ROWCOUNT => 30))
),
"Compared Trend 1_metric_per_time_window" AS (
SELECT
h.warehouse_name,
t."WINDOW_END",
SUM(h.credits_used) AS "METRIC_VALUE"
FROM TABLE(information_schema.warehouse_metering_history(
dateadd('day', -31, current_timestamp()),
dateadd('hours', -1, current_timestamp())
)) h
JOIN "Compared Trend 1_time_windows" t
ON t."WINDOW_START" <= h.start_time
AND t."WINDOW_END" >= h.start_time
GROUP BY h.warehouse_name, t."WINDOW_END"
),
"Compared Trend 1" AS (
SELECT
warehouse_name,
MAX("METRIC_VALUE") AS "COMPARED_VALUE",
MAX("METRIC_VALUE") * (1 + 0.3) AS "COMPARED_VALUE_THRESHOLD"
FROM "Compared Trend 1_metric_per_time_window"
GROUP BY warehouse_name
)
SELECT
m.warehouse_name,
m."METRIC_VALUE",
m.compute_credits,
m.cloud_credits,
c."COMPARED_VALUE",
c."COMPARED_VALUE_THRESHOLD",
CASE WHEN m."METRIC_VALUE" > c."COMPARED_VALUE_THRESHOLD"
THEN 'SPIKE' ELSE 'Normal'
END AS status
FROM "main_metric" m
LEFT JOIN "Compared Trend 1" c ON m.warehouse_name = c.warehouse_name
ORDER BY m."METRIC_VALUE" DESC
) AS subquery
LIMIT 1000Sample alert
⚠️ Warehouse Credit Spike — COMPUTE_WH used 12.4 credits in the last 24h. 30-day max: 3.1 credits · 4× above baseline.