You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Setting Up Mail Notification on Failed Task Execution
143
+
144
+
Snowflake provides build in alert/notification functionality. This "ALERT" object holds a condition that you can specify and use to check if tasks have failed and send notifications based on your conditional expression. To use this you need to create a ["NOTIFICATION INTEGRATION"](https://docs.snowflake.com/en/sql-reference/sql/create-notification-integration-email) and ["ALERT"]() using the NOTIFICATION INTEGRATION and system function ["SYSTEM$SEND_EMAIL"](https://docs.snowflake.com/en/sql-reference/stored-procedures/system_send_email).
145
+
146
+
### SQL to Setup Mail Notification
147
+
148
+
The following is an template you can use after filling in the specifics:
149
+
150
+
```sql
151
+
CREATEDATABASEIF NOT EXISTS <db name>;
152
+
153
+
CREATESCHEMAIF NOT <schema name>;
154
+
155
+
USE SCHEMA <schema name>;
156
+
157
+
CREATE OR REPLACE NOTIFICATION INTEGRATION <NOTIFICATION INTEGRATION name>
SCHEDULE ='<integer> MINUTE'-- Or use CRON e.g. 15 * * * * UTC
165
+
IF (
166
+
EXISTS (
167
+
SELECT1
168
+
FROMSNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY
169
+
WHERE (STATE ='FAILED'OR STATE ='FAILED_AND_AUTO_SUSPENDED') AND NAME ='<task name>'
170
+
AND SCHEDULED_TIME >= CONVERT_TIMEZONE('UTC',DATEADD(MINUTE, -<integer>, CURRENT_TIMESTAMP()))
171
+
)
172
+
)
173
+
THEN CALL SYSTEM$SEND_EMAIL(
174
+
'<NOTIFICATION INTEGRATION name>',
175
+
('<mail1@company.com>', '<mail5@company.com>', ...) --Subset of ALLOWED_RECIPIENTS in NOTIFICATION INTEGRATION.
176
+
'<Mail subject>',
177
+
'<Mail Body>.'
178
+
);
179
+
180
+
ALTER ALERT <ALERT name> RESUME; -- The ALERT has STATE Suspended when created and is started by this statement
181
+
182
+
SHOW ALERTS;
183
+
```
142
184
## Verifying the Access Token
143
185
144
186
When using OAuth authentication with the Mendix Data Loader, it is crucial to verify the access token received by your Mendix application. This verification process ensures the token's authenticity and integrity, protecting your application from unauthorized access attempts.
0 commit comments