Skip to main content

alerts

Creates, updates, deletes, gets or lists an alerts resource.

Overview

Namealerts
TypeResource
Idsnowflake.alert.alerts

Fields

The following fields are returned by SELECT queries:

A Snowflake alert

NameDatatypeDescription
namestringName of the alert
database_namestringDatabase in which the alert is stored
schema_namestringSchema in which the alert is stored
actionstringThe SQL statement to execute when the alert is triggered
commentstringuser comment associated to an object in the dictionary
conditionstringThe SQL statement that must be evaluated to determine whether to trigger the alert
created_onstring (date-time)Date and time when the alert was created.
ownerstringRole that owns the alert
owner_role_typestringThe type of role that owns the alert
scheduleobject
statestringThe current state of the alert
warehousestringThe warehouse the alert runs in

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_alertsselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameList alerts
fetch_alertselectdatabase_name, schema_name, name, endpointFetch an alert
create_alertinsertdatabase_name, schema_name, endpointcreateModeCreate an alert
delete_alertdeletedatabase_name, schema_name, name, endpointifExistsDelete an alert
clone_alertexecdatabase_name, schema_name, name, targetDatabase, targetSchema, endpointcreateModeCreate a new alert by cloning from the specified resource
execute_alertexecdatabase_name, schema_name, name, endpointExecute an alert

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringIdentifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases.
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database.
targetDatabasestringDatabase of the newly created resource. Defaults to the source's database
targetSchemastringSchema of the newly created resource. Defaults to the source's schema
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
fromNamestringQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerQuery parameter to limit the maximum number of rows returned by a command.
startsWithstringQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.

SELECT examples

List alerts

SELECT
name,
database_name,
schema_name,
action,
comment,
condition,
created_on,
owner,
owner_role_type,
schedule,
state,
warehouse
FROM snowflake.alert.alerts
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';

INSERT examples

Create an alert

INSERT INTO snowflake.alert.alerts (
data__name,
data__comment,
data__schedule,
data__warehouse,
data__condition,
data__action,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ comment }}',
'{{ schedule }}' --required,
'{{ warehouse }}',
'{{ condition }}' --required,
'{{ action }}' --required,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
;

DELETE examples

Delete an alert

DELETE FROM snowflake.alert.alerts
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';

Lifecycle Methods

Create a new alert by cloning from the specified resource

EXEC snowflake.alert.alerts.clone_alert 
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetDatabase='{{ targetDatabase }}' --required,
@targetSchema='{{ targetSchema }}' --required,
@endpoint='{{ endpoint }}' --required,
@createMode='{{ createMode }}'
@@json=
'{
"name": "{{ name }}",
"point_of_time": "{{ point_of_time }}"
}';