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 ParamsDescription
fetch_alertSELECTdatabase_name, name, schema_name, endpointFetch an alert
list_alertsSELECTdatabase_name, schema_name, endpointList alerts
create_alertINSERTdatabase_name, schema_name, data__action, data__condition, data__name, data__schedule, endpointCreate an alert
delete_alertDELETEdatabase_name, name, schema_name, endpointDelete an alert
clone_alertEXECdatabase_name, name, schema_name, targetDatabase, targetSchema, data__name, endpointCreate a new alert by cloning from the specified resource
execute_alertEXECdatabase_name, name, schema_name, endpointExecute an alert

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 }}';