Skip to main content

alerts

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

Overview

Namealerts
TypeResource
Idsnowflake.alert.alerts

Fields

NameDatatypeDescription
namestringName of the alert
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_onstringDate and time when the alert was created.
database_namestringDatabase in which the alert is stored
ownerstringRole that owns the alert
owner_role_typestringThe type of role that owns the alert
scheduleobject
schema_namestringSchema in which the alert is stored
statestringThe current state of the alert
warehousestringThe warehouse the alert runs in

Methods

NameAccessible byRequired ParamsOptional ParamsDescription
fetch_alertSELECTdatabase_name, name, schema_name, endpoint-Fetch an alert
list_alertsSELECTdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameList alerts
create_alertINSERTdatabase_name, schema_name, data__action, data__condition, data__name, data__schedule, endpointcreateModeCreate an alert
delete_alertDELETEdatabase_name, name, schema_name, endpointifExistsDelete an alert
clone_alertEXECdatabase_name, name, schema_name, targetDatabase, targetSchema, data__name, endpointcreateModeCreate a new alert by cloning from the specified resource
execute_alertEXECdatabase_name, name, schema_name, endpoint-Execute an alert

Optional Parameter Details
NameDescriptionTypeDefault
createModeQuery 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.stringerrorIfExists
fromNameQuery 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.string-
ifExistsQuery 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.booleanfalse
likeQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.string-
showLimitQuery parameter to limit the maximum number of rows returned by a command.integer-
startsWithQuery 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.string-

SELECT examples

List alerts

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

INSERT example

Use the following StackQL query and manifest file to create a new alerts resource.

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

DELETE example

Deletes the specified alerts resource.

/*+ delete */
DELETE FROM snowflake.alert.alerts
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';