alerts
Creates, updates, deletes, gets or lists an alerts
resource.
Overview
Name | alerts |
Type | Resource |
Id | snowflake.alert.alerts |
Fields
The following fields are returned by SELECT
queries:
- list_alerts
- fetch_alert
A Snowflake alert
Name | Datatype | Description |
---|---|---|
name | string | Name of the alert |
database_name | string | Database in which the alert is stored |
schema_name | string | Schema in which the alert is stored |
action | string | The SQL statement to execute when the alert is triggered |
comment | string | user comment associated to an object in the dictionary |
condition | string | The SQL statement that must be evaluated to determine whether to trigger the alert |
created_on | string (date-time) | Date and time when the alert was created. |
owner | string | Role that owns the alert |
owner_role_type | string | The type of role that owns the alert |
schedule | object | |
state | string | The current state of the alert |
warehouse | string | The warehouse the alert runs in |
A Snowflake alert
Name | Datatype | Description |
---|---|---|
name | string | Name of the alert |
database_name | string | Database in which the alert is stored |
schema_name | string | Schema in which the alert is stored |
action | string | The SQL statement to execute when the alert is triggered |
comment | string | user comment associated to an object in the dictionary |
condition | string | The SQL statement that must be evaluated to determine whether to trigger the alert |
created_on | string (date-time) | Date and time when the alert was created. |
owner | string | Role that owns the alert |
owner_role_type | string | The type of role that owns the alert |
schedule | object | |
state | string | The current state of the alert |
warehouse | string | The warehouse the alert runs in |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
list_alerts | select | database_name , schema_name , endpoint | like , startsWith , showLimit , fromName | List alerts |
fetch_alert | select | database_name , schema_name , name , endpoint | Fetch an alert | |
create_alert | insert | database_name , schema_name , endpoint | createMode | Create an alert |
delete_alert | delete | database_name , schema_name , name , endpoint | ifExists | Delete an alert |
clone_alert | exec | database_name , schema_name , name , targetDatabase , targetSchema , endpoint | createMode | Create a new alert by cloning from the specified resource |
execute_alert | exec | database_name , schema_name , name , endpoint | Execute 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.
Name | Datatype | Description |
---|---|---|
database_name | string | Identifier (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. |
endpoint | string | Organization and Account Name (default: orgid-acctid) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (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. |
targetDatabase | string | Database of the newly created resource. Defaults to the source's database |
targetSchema | string | Schema of the newly created resource. Defaults to the source's schema |
createMode | string | Query 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. |
fromName | string | Query 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. |
ifExists | boolean | Query 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. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Query parameter to limit the maximum number of rows returned by a command. |
startsWith | string | Query 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
- fetch_alert
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 }}';
Fetch an alert
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 name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- create_alert
- Manifest
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 }}'
;
# Description fields are for documentation purposes
- name: alerts
props:
- name: database_name
value: string
description: Required parameter for the alerts resource.
- name: schema_name
value: string
description: Required parameter for the alerts resource.
- name: endpoint
value: string
description: Required parameter for the alerts resource.
- name: name
value: string
description: >
Name of the alert
- name: comment
value: string
description: >
user comment associated to an object in the dictionary
- name: schedule
value: object
- name: warehouse
value: string
description: >
The warehouse the alert runs in
- name: condition
value: string
description: >
The SQL statement that must be evaluated to determine whether to trigger the alert
- name: action
value: string
description: >
The SQL statement to execute when the alert is triggered
- name: createMode
value: string
description: Query 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.
DELETE
examples
- delete_alert
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
- clone_alert
- execute_alert
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 }}"
}';
Execute an alert
EXEC snowflake.alert.alerts.execute_alert
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required;