Skip to main content

alerts

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

Overview

Namealerts
TypeResource
Iddatabricks_workspace.sql.alerts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUUID identifying the alert.
query_idstringUUID of the query attached to the alert.
display_namestringThe display name of the alert.
owner_user_namestringThe owner's username. This field is set to "Unavailable" if the user has been deleted.
conditionobject
create_timestringThe timestamp indicating when the alert was created.
custom_bodystringCustom body of alert notification, if it exists. See [here] for custom templating instructions. [here]: https://docs.databricks.com/sql/user/alerts/index.html
custom_subjectstringCustom subject of alert notification, if it exists. This can include email subject entries and Slack notification headers, for example. See [here] for custom templating instructions. [here]: https://docs.databricks.com/sql/user/alerts/index.html
lifecycle_statestringThe workspace state of the alert. Used for tracking trashed status. (ACTIVE, TRASHED)
notify_on_okbooleanWhether to notify alert subscribers when alert returns back to normal.
parent_pathstringThe workspace path of the folder containing the alert.
seconds_to_retriggerintegerNumber of seconds an alert must wait after being triggered to rearm itself. After rearming, it can be triggered again. If 0 or not specified, the alert will not be triggered again.
statestringCreate a collection of name/value pairs.<br /><br />Example enumeration:<br /><br />&gt;&gt;&gt; class Color(Enum):<br />... RED = 1<br />... BLUE = 2<br />... GREEN = 3<br /><br />Access them by:<br /><br />- attribute access::<br /><br />&gt;&gt;&gt; Color.RED<br />&lt;Color.RED: 1&gt;<br /><br />- value lookup:<br /><br />&gt;&gt;&gt; Color(1)<br />&lt;Color.RED: 1&gt;<br /><br />- name lookup:<br /><br />&gt;&gt;&gt; Color['RED']<br />&lt;Color.RED: 1&gt;<br /><br />Enumerations can be iterated over, and know how many members they have:<br /><br />&gt;&gt;&gt; len(Color)<br />3<br /><br />&gt;&gt;&gt; list(Color)<br />[&lt;Color.RED: 1&gt;, &lt;Color.BLUE: 2&gt;, &lt;Color.GREEN: 3&gt;]<br /><br />Methods can be added to enumerations, and members can have their own<br />attributes -- see the documentation for details. (OK, TRIGGERED, UNKNOWN)
trigger_timestringTimestamp when the alert was last triggered, if the alert has been triggered before.
update_timestringThe timestamp indicating when the alert was updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid, deployment_nameGets an alert.
listselectdeployment_namepage_size, page_tokenGets a list of alerts accessible to the user, ordered by creation time. Warning: Calling this API
createinsertdeployment_nameCreates an alert.
updateupdateid, deployment_name, update_maskUpdates an alert.
deletedeleteid, deployment_nameMoves an alert to the trash. Trashed alerts immediately disappear from searches and list views, and

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.

NameDatatypeDescription
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
idstringstr
page_sizeinteger:param page_token: str (optional)
page_tokenstring

SELECT examples

Gets an alert.

SELECT
id,
query_id,
display_name,
owner_user_name,
condition,
create_time,
custom_body,
custom_subject,
lifecycle_state,
notify_on_ok,
parent_path,
seconds_to_retrigger,
state,
trigger_time,
update_time
FROM databricks_workspace.sql.alerts
WHERE id = '{{ id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Creates an alert.

INSERT INTO databricks_workspace.sql.alerts (
alert,
auto_resolve_display_name,
deployment_name
)
SELECT
'{{ alert }}',
{{ auto_resolve_display_name }},
'{{ deployment_name }}'
RETURNING
id,
query_id,
display_name,
owner_user_name,
condition,
create_time,
custom_body,
custom_subject,
lifecycle_state,
notify_on_ok,
parent_path,
seconds_to_retrigger,
state,
trigger_time,
update_time
;

UPDATE examples

Updates an alert.

UPDATE databricks_workspace.sql.alerts
SET
update_mask = '{{ update_mask }}',
alert = '{{ alert }}',
auto_resolve_display_name = {{ auto_resolve_display_name }}
WHERE
id = '{{ id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND update_mask = '{{ update_mask }}' --required
RETURNING
id,
query_id,
display_name,
owner_user_name,
condition,
create_time,
custom_body,
custom_subject,
lifecycle_state,
notify_on_ok,
parent_path,
seconds_to_retrigger,
state,
trigger_time,
update_time;

DELETE examples

Moves an alert to the trash. Trashed alerts immediately disappear from searches and list views, and

DELETE FROM databricks_workspace.sql.alerts
WHERE id = '{{ id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;