Schedule icon
Query icon
Return icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Snowflake Warehouse Credit Usage and FinOps Cost Guard

Monitor Snowflake warehouse credit consumption and prevent runaway cloud billing with Kestra. Query ACCOUNT_USAGE, track GitHub issues, and notify Slack.

Categories
CloudData

Cloud data warehouses like Snowflake offer elastic scaling, but unoptimized queries, runaway ETL jobs, or excessive auto-suspend timeouts can rapidly burn through expensive credit allocations. Without automated governance, data platform leaders only discover credit spikes on the monthly invoice. This blueprint interrogates Snowflake's ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY hourly, detects credit consumption spikes breaching predefined thresholds, logs an auditable GitHub FinOps ticket, and notifies data platform engineers on Slack.

How it works

  1. hourly_warehouse_governance_check (io.kestra.plugin.core.trigger.Schedule) initiates the audit every hour (shipped disabled for safe verification).
  2. probe_warehouse_credit_usage (io.kestra.plugin.jdbc.snowflake.Query) queries the Snowflake ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY view via JDBC for credits consumed across compute and cloud services in the preceding hour.
  3. evaluate_credit_surge (io.kestra.plugin.core.debug.Return) calculates if total credit consumption breached the hourly threshold.
  4. branch_on_credit_surge (io.kestra.plugin.core.flow.If) evaluates the condition:
    • then: Automatically files a GitHub tracking issue via create_finops_github_issue (io.kestra.plugin.github.issues.Create) and alerts the Slack channel via alert_finops_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Emits an informational log entry (log_warehouse_compliant) confirming normal credit usage.
  5. log_audit_summary (io.kestra.plugin.core.log.Log) records the audit outcome.
  6. The errors block alerts Slack if Snowflake JDBC connection fails or credentials expire.

What you get

  • Automated, hourly visibility into Snowflake warehouse credit consumption.
  • Early warning before minor query mistakes escalate into major cloud invoice surprises.
  • Automated GitHub tracking issues documenting compute vs cloud service credit breakdowns.
  • Real-time Slack notifications for immediate query optimization.

Who it's for

  • Data Platform Engineers and FinOps teams managing corporate Snowflake accounts.
  • Analytics Engineers optimizing dbt and warehouse transformation schedules.
  • Engineering Managers monitoring cloud data warehouse spend.

Why orchestrate this with Kestra

Kestra simplifies multi-system governance by connecting Snowflake JDBC querying, conditional thresholding, GitHub issue management, and Slack alerting into a single declarative pipeline. It handles secrets securely, provides complete execution history, and eliminates the need for external Lambda functions or custom cron wrappers.

Prerequisites

  • A Snowflake account with access to the SNOWFLAKE.ACCOUNT_USAGE schema.
  • A Snowflake user with a role possessing read permissions on warehouse metering history.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • SNOWFLAKE_ACCOUNT: Snowflake account locator or organization identifier.
  • SNOWFLAKE_USERNAME, SNOWFLAKE_PASSWORD: Credentials for Snowflake authentication.
  • GITHUB_TOKEN: GitHub token used to open FinOps issues.
  • SLACK_WEBHOOK: Slack Incoming Webhook URL for alerting.

Inputs

  • warehouse_name (STRING, default COMPUTE_WH): Name of the Snowflake virtual warehouse to audit.
  • credit_threshold (FLOAT, default 15.0): Maximum tolerated hourly credit consumption before alerting.
  • github_repository (STRING, default my-org/snowflake-cost-governance): Target GitHub repository for logging FinOps issues.

Outputs

  • outputs.probe_warehouse_credit_usage.row: Aggregated credit metrics row returned by Snowflake.
  • outputs.evaluate_credit_surge.value: Extracted evaluation object with credit breakdowns and surge boolean flag.

Quick start

  1. Configure the SNOWFLAKE_ACCOUNT, SNOWFLAKE_USERNAME, SNOWFLAKE_PASSWORD, GITHUB_TOKEN, and SLACK_WEBHOOK secrets.
  2. Import this flow and set warehouse_name to match an active Snowflake warehouse.
  3. Trigger a manual execution to verify JDBC connection and credit calculation.
  4. Enable the hourly_warehouse_governance_check trigger for continuous automated FinOps monitoring.

How to extend

  • Add an automated ALTER WAREHOUSE SUSPEND statement gated behind manual approval to immediately halt runaway warehouses.
  • Pull query history details from QUERY_HISTORY to automatically identify the specific queries that consumed the most credits.
  • Integrate with Jira or PagerDuty for critical production billing incidents.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.