alerts
Creates, updates, deletes, gets or lists an alerts resource.
Overview
| Name | alerts |
| Type | Resource |
| Id | snowflake.pipelines.alerts |
Fields
The following fields are returned by SELECT queries:
- get
- list
successful
| 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 | The schedule the alert runs under |
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 | The schedule the alert runs under |
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 |
|---|---|---|---|---|
get | select | database_name, schema_name, name, endpoint | Fetch an alert | |
list | select | database_name, schema_name, endpoint | like, startsWith, showLimit, fromName | List alerts |
create | insert | database_name, schema_name, endpoint, name, schedule, condition, action | createMode | Create an alert |
delete | delete | database_name, schema_name, name, endpoint | ifExists | Delete an alert |
clone | exec | database_name, schema_name, name, targetDatabase, targetSchema, endpoint, name | createMode | Create a new alert by cloning from the specified resource |
execute | 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 identifier (orgname-accountname) (default: orgname-accountname) |
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 | 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 | 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 | 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 | Parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Parameter to limit the maximum number of rows returned by a command. |
startsWith | string | 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
- get
- list
Fetch an alert
SELECT
name,
database_name,
schema_name,
action,
comment,
condition,
created_on,
owner,
owner_role_type,
schedule,
state,
warehouse
FROM snowflake.pipelines.alerts
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;
List alerts
SELECT
name,
database_name,
schema_name,
action,
comment,
condition,
created_on,
owner,
owner_role_type,
schedule,
state,
warehouse
FROM snowflake.pipelines.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
- Manifest
Create an alert
INSERT INTO snowflake.pipelines.alerts (
name,
comment,
schedule,
warehouse,
condition,
action,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' /* required */,
'{{ comment }}',
'{{ schedule }}' /* required */,
'{{ warehouse }}',
'{{ condition }}' /* required */,
'{{ action }}' /* required */,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;
# Description fields are for documentation purposes
- name: alerts
props:
- name: database_name
value: "{{ database_name }}"
description: Required parameter for the alerts resource.
- name: schema_name
value: "{{ schema_name }}"
description: Required parameter for the alerts resource.
- name: endpoint
value: "{{ endpoint }}"
description: Required parameter for the alerts resource.
- name: name
value: "{{ name }}"
description: |
Name of the alert
- name: comment
value: "{{ comment }}"
description: |
user comment associated to an object in the dictionary
- name: schedule
description: |
The schedule the alert runs under
value:
schedule_type: "{{ schedule_type }}"
- name: warehouse
value: "{{ warehouse }}"
description: |
The warehouse the alert runs in
- name: condition
value: "{{ condition }}"
description: |
The SQL statement that must be evaluated to determine whether to trigger the alert
- name: action
value: "{{ action }}"
description: |
The SQL statement to execute when the alert is triggered
- name: createMode
value: "{{ createMode }}"
description: 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.
description: 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
Delete an alert
DELETE FROM snowflake.pipelines.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
- execute
Create a new alert by cloning from the specified resource
EXEC snowflake.pipelines.alerts.clone
@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.pipelines.alerts.execute
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required
;