Configuring a task to send error notifications

To enable a task to send error notifications, you must associate the task with a notification integration. You can do this when running the CREATE TASK command to create a new task or the ALTER TASK command to modify an existing task. When running these commands, set ERROR_NOTIFICATION to the name of the notification integration.

You only specify the error notification integrations on a root task of a task graph; any failed child task sends error notifications to the root task’s specified integration.

Tasks with TASK_AUTO_RETRY_ATTEMPTS set to a value greater than 0 send error notifications for each failed task run.

Note

Creating or modifying a task that references a notification integration requires a role that has the USAGE privilege on the notification integration. In addition, the role must have either the CREATE TASK privilege on the schema or the OWNERSHIP privilege on the task, respectively.

Creating a new task that sends error notifications

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>
Copy

Where:

ERROR_INTEGRATION = integration_name

Name of the notification integration created in one of AWS SNS, Google Pub/Sub, or Azure Event Grid platform level notifications.

The following example creates a serverless task that supports error notifications. The task inserts the current timestamp into a table column every 5 minutes:

CREATE TASK mytask
  SCHEDULE = '5 MINUTE'
  ERROR_INTEGRATION = my_notification_int
  AS
  INSERT INTO mytable(ts) VALUES(CURRENT_TIMESTAMP);
Copy

Updating an existing task to send error notifications

Modify an existing task using ALTER TASK:

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

Where integration_name is the name of the notification integration created in one of AWS SNS, Google Pub/Sub, or Azure Event Grid platform level notifications.

For example:

ALTER TASK mytask SET ERROR_INTEGRATION = my_notification_int;
Copy