Skip to main content

alerts_v2

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

Overview

Namealerts_v2
TypeResource
Iddatabricks_workspace.sql.alerts_v2

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUUID identifying the alert.
warehouse_idstringID of the SQL warehouse attached to the alert.
display_namestring
owner_user_namestringThe owner's username. This field is set to "Unavailable" if the user has been deleted.
run_as_user_namestringThe run as username or application ID of service principal. On Create and Update, this field can be set to application ID of an active service principal. Setting this field requires the servicePrincipal/user role. Deprecated: Use `run_as` field instead. This field will be removed in a future release.
create_timestringThe timestamp indicating when the alert was created.
custom_descriptionstringCustom description for the alert. support mustache template.
custom_summarystringCustom summary for the alert. support mustache template.
effective_run_asobjectThe actual identity that will be used to execute the alert. This is an output-only field that shows the resolved run-as identity after applying permissions and defaults.
evaluationobject
lifecycle_statestringIndicates whether the query is trashed. (ACTIVE, DELETED)
parent_pathstringThe workspace path of the folder containing the alert. Can only be set on create, and cannot be updated.
query_textstringText of the query to be run.
run_asobjectSpecifies the identity that will be used to run the alert. This field allows you to configure alerts to run as a specific user or service principal. - For user identity: Set `user_name` to the email of an active workspace user. Users can only set this to their own email. - For service principal: Set `service_principal_name` to the application ID. Requires the `servicePrincipal/user` role. If not specified, the alert will run as the request user.
scheduleobject
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.
createinsertdeployment_name, alertCreate Alert
updateupdateid, update_mask, deployment_name, alertUpdate alert
deletedeleteid, deployment_namepurgeMoves an alert to the trash. Trashed alerts immediately disappear from list views, and can no longer

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)
idstring:param purge: bool (optional) Whether to permanently delete the alert. If not set, the alert will only be soft deleted.
update_maskstring
page_sizeinteger:param page_token: str (optional)
page_tokenstring
purgeboolean

SELECT examples

Gets an alert.

SELECT
id,
warehouse_id,
display_name,
owner_user_name,
run_as_user_name,
create_time,
custom_description,
custom_summary,
effective_run_as,
evaluation,
lifecycle_state,
parent_path,
query_text,
run_as,
schedule,
update_time
FROM databricks_workspace.sql.alerts_v2
WHERE id = '{{ id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Create Alert

INSERT INTO databricks_workspace.sql.alerts_v2 (
alert,
deployment_name
)
SELECT
'{{ alert }}' /* required */,
'{{ deployment_name }}'
RETURNING
id,
warehouse_id,
display_name,
owner_user_name,
run_as_user_name,
create_time,
custom_description,
custom_summary,
effective_run_as,
evaluation,
lifecycle_state,
parent_path,
query_text,
run_as,
schedule,
update_time
;

UPDATE examples

Update alert

UPDATE databricks_workspace.sql.alerts_v2
SET
alert = '{{ alert }}'
WHERE
id = '{{ id }}' --required
AND update_mask = '{{ update_mask }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND alert = '{{ alert }}' --required
RETURNING
id,
warehouse_id,
display_name,
owner_user_name,
run_as_user_name,
create_time,
custom_description,
custom_summary,
effective_run_as,
evaluation,
lifecycle_state,
parent_path,
query_text,
run_as,
schedule,
update_time;

DELETE examples

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

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