Day 2: Streamline Alerts in Snowflake: How to Use SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
We are on Day 2 of our continuous series on Snowflake insights. Today, we’ll explore the SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
feature.
What is SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
?
This function allows you to send notifications to various destinations (such as email, webhooks, or queues) with flexible message formats.
How to Use SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
?
In this blog, I will explain how to send email notifications using SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
.
Before sending a notification, you must set up a notification integration to use with the function. If you’re sending email notifications, it’s also necessary to validate the recipient email addresses.
Step 1: Creation of Notification Integration:
CREATE OR REPLACE NOTIFICATION INTEGRATION Email_Integration_Test -- Creates a new notification integration or replaces an existing one with the same name
TYPE=EMAIL -- Specifies the type of integration as email
ENABLED=TRUE -- Enables the notification integration for use
ALLOWED_RECIPIENTS=('XXXXXXX@gmail.com'), -- Defines a list of allowed recipient email addresses
DEFAULT_RECIPIENTS = ('XXXXXXX@gmail.com') -- Sets the default recipient list for notifications using this integration
DEFAULT_SUBJECT = 'Snowflake Notification - Testing' -- Subject line of the Email
COMMENT = 'This notification created for Testing for SEND_NOTIFICATION_INTEGRATION' -- Comment line to explain the Integration
Output:
Step 2: Code to Send Email Using SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
After creating the notification integration (Email_Integration_Test
) in Step 1, you can use the following code to send an email notification using SYSTEM$SEND_SNOWFLAKE_NOTIFICATION
CALL SYSTEM$SEND_SNOWFLAKE_NOTIFICATION(
SNOWFLAKE.NOTIFICATION.TEXT_HTML(
'<html>
<head>
<title>Welcome to Snowflake</title>
</head>
<body>
<h1>Welcome to Snowflake</h1>
<p>Testing the Snowflake.Notification!!!</p>
</body>
</html>'
),
SNOWFLAKE.NOTIFICATION.INTEGRATION('Email_Integration_Test')
);
Output:
After running the procedure described in Step 2, the notification got triggered and sent to the email address specified in Step 1.
Flexible Notification Formats in Snowflake:
The Snowflake notification integration supports sending notifications in different formats, such as
- Plain Text
- HTML
- JSON (commonly used for queues)
In the example above, I used the HTML format to send the notification.
Stay Updated!
If you enjoyed this blog and would like to receive short and insightful notification messages directly, feel free to subscribe to my updates.
Thank you for all your support! Stay tuned for more Snowflake tips and tricks.
About me:
I am a Cloud Data Architect at EY New Zealand. Over the course of my career, I have led and contributed to numerous projects, including legacy data warehouse modernization, big data implementations, cloud platform integrations, and migration initiatives. If you require assistance with certification, data solutions, or implementations, please feel free to connect with me on LinkedIn.