alerts
Creates, updates, deletes, gets or lists a alerts
resource.
Overview
Name | alerts |
Type | Resource |
Id | snowflake.alert.alerts |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Name of the alert |
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 and time when the alert was created. |
database_name | string | Database in which the alert is stored |
owner | string | Role that owns the alert |
owner_role_type | string | The type of role that owns the alert |
schedule | object | |
schema_name | string | Schema in which the alert is stored |
state | string | The current state of the alert |
warehouse | string | The warehouse the alert runs in |
Methods
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
fetch_alert | SELECT | database_name, name, schema_name, endpoint | - | Fetch an alert |
list_alerts | SELECT | database_name, schema_name, endpoint | like , startsWith , showLimit , fromName | List alerts |
create_alert | INSERT | database_name, schema_name, data__action, data__condition, data__name, data__schedule, endpoint | createMode | Create an alert |
delete_alert | DELETE | database_name, name, schema_name, endpoint | ifExists | Delete an alert |
clone_alert | EXEC | database_name, name, schema_name, targetDatabase, targetSchema, data__name, endpoint | createMode | Create a new alert by cloning from the specified resource |
execute_alert | EXEC | database_name, name, schema_name, endpoint | - | Execute an alert |
Optional Parameter Details
Name | Description | Type | Default |
---|---|---|---|
createMode | 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. | string | errorIfExists |
fromName | 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. | string | - |
ifExists | 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. | boolean | false |
like | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. | string | - |
showLimit | Query parameter to limit the maximum number of rows returned by a command. | integer | - |
startsWith | 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. | 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.
- Required Properties
- All Properties
- Manifest
/*+ 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 }}'
;
/*+ create */
INSERT INTO snowflake.alert.alerts (
data__name,
data__schedule,
data__condition,
data__action,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ schedule }}',
'{{ condition }}',
'{{ action }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
- name: alerts
props:
- name: database_name
value: string
- name: schema_name
value: string
- name: data__action
value: string
- name: data__condition
value: string
- name: data__name
value: string
- name: data__schedule
value: string
- name: endpoint
value: string
- name: name
value: string
- name: comment
value: string
- name: schedule
props:
- name: schedule_type
value: string
- name: warehouse
value: string
- name: condition
value: string
- name: action
value: string
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 }}';