New to Kestra?
Use blueprints to kickstart your first workflows.
Detect Snowflake queries running beyond a configurable execution threshold and alert Slack with query IDs, user names, and warehouse details.
Runaway queries in Snowflake waste credits, block warehouse capacity, and can cascade into pipeline failures. Without automated detection, long-running queries often go unnoticed until a downstream dbt model times out or an invoice arrives. This sentinel queries SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY every 15 minutes for queries in RUNNING state that exceed the configured execution time threshold and fires a Slack alert with the offending query IDs, users, warehouses, and runtime in minutes.
query_long_running (io.kestra.plugin.jdbc.snowflake.Query) connects over JDBC and retrieves up to 10 queries currently in RUNNING state whose execution time exceeds inputs.execution_time_ms_threshold milliseconds, ordered by duration descending.check_long_queries (io.kestra.plugin.core.flow.If) evaluates whether the result set is non-empty.alert_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts a Slack message listing each query ID, owner, warehouse, and runtime in minutes.log_ok (io.kestra.plugin.core.log.Log) records a clean check, confirming no runaway queries were found.errors block fires a Slack alert if the JDBC query itself cannot complete, preventing silent monitoring blackouts.Schedule trigger fires every 15 minutes and ships disabled.Snowflake does not provide native push alerts for long-running queries. Third-party monitoring tools can query QUERY_HISTORY but require additional infrastructure and credential management. Kestra encapsulates the query, conditional evaluation, Slack dispatch, and error handling in a single, version-controlled YAML flow with full execution history, without any extra servers or agents.
SELECT on SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY.SNOWFLAKE_PASSWORD: Password for the Snowflake user in inputs.username.SLACK_WEBHOOK: Slack incoming webhook URL.SNOWFLAKE_PASSWORD and SLACK_WEBHOOK in your Kestra namespace secrets.account, username, and execution_time_ms_threshold (default is 1 800 000 ms = 30 minutes).Schedule trigger for continuous 15-minute monitoring.io.kestra.plugin.jdbc.snowflake.Query task in the then branch to call SELECT SYSTEM$CANCEL_QUERY('<query_id>') and terminate runaway queries automatically after approval.LIMIT and the one-hour lookback window as additional inputs for broader coverage.