vvazza
vvazza

Reputation: 397

Snowflake task failure notification

I have Snowflake tasks that runs every 30 minutes. Currently, when the task fails due to underlying data issue in the stored procedure that the Task calls, there is no way to notify the users on the failure.

SELECT *
FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY());

How can notifications be setup for a Snowflake Task failure? The design plan I have in mind is to build a python application that runs every 30mins and looks for any error on TASK_HISTORY table. Please advise if there are any better approaches to handle failure notifications

Upvotes: 2

Views: 4954

Answers (3)

P Needleman
P Needleman

Reputation: 247

A new Snowflake feature was announced for Task Error Notifications on AWS via SNS. This doc walks though how to set this up for task failures.

https://docs.snowflake.com/en/user-guide/tasks-errors.html

Upvotes: 0

Lukasz Szozda
Lukasz Szozda

Reputation: 175606

It is possible to create Notification Integration and send message when error occurs. As of May 2022 this feature is in preview, supported by accounts on Amazon Web Servives.

Enabling Error Notifications for Tasks

This topic provides instructions for configuring error notification support for tasks using cloud messaging. This feature triggers a notification describing the errors encountered when a task executes SQL code

Currently, error notifications rely on cloud messaging provided by the
Amazon Simple Notification Service service;
support for Google Cloud Pub/Sub queue and Microsoft Azure Event Grid is planned. 

New Tasks

Create a new task using CREATE TASK. For descriptions of all available task parameters, see the SQL command topic:

CREATE TASK <name>
 [...]
 ERROR_INTEGRATION = <integration_name>
 AS <sql>

Existing tasks:

ALTER TASK <name> SET ERROR_INTEGRATION = <integration_name>;  

Upvotes: 1

demircioglu
demircioglu

Reputation: 3455

I think currently a python script would the best way to address this. You can use this SQL to query last runs, read into a data frame and filter out errors

select *
  from table(information_schema.task_history(scheduled_time_range_start=>dateadd(minutes, -30,current_timestamp())))

Upvotes: 4

Related Questions