alerts_v2
Creates, updates, deletes, gets or lists an alerts_v2 resource.
Overview
| Name | alerts_v2 |
| Type | Resource |
| Id | databricks_workspace.sql.alerts_v2 |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
id | string | UUID identifying the alert. |
warehouse_id | string | ID of the SQL warehouse attached to the alert. |
display_name | string | |
owner_user_name | string | The owner's username. This field is set to "Unavailable" if the user has been deleted. |
run_as_user_name | string | The 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_time | string | The timestamp indicating when the alert was created. |
custom_description | string | Custom description for the alert. support mustache template. |
custom_summary | string | Custom summary for the alert. support mustache template. |
effective_run_as | object | The 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. |
evaluation | object | |
lifecycle_state | string | Indicates whether the query is trashed. (ACTIVE, DELETED) |
parent_path | string | The workspace path of the folder containing the alert. Can only be set on create, and cannot be updated. |
query_text | string | Text of the query to be run. |
run_as | object | Specifies 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. |
schedule | object | |
update_time | string | The timestamp indicating when the alert was updated. |
| Name | Datatype | Description |
|---|---|---|
id | string | UUID identifying the alert. |
warehouse_id | string | ID of the SQL warehouse attached to the alert. |
display_name | string | |
owner_user_name | string | The owner's username. This field is set to "Unavailable" if the user has been deleted. |
run_as_user_name | string | The 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_time | string | The timestamp indicating when the alert was created. |
custom_description | string | Custom description for the alert. support mustache template. |
custom_summary | string | Custom summary for the alert. support mustache template. |
effective_run_as | object | The 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. |
evaluation | object | |
lifecycle_state | string | Indicates whether the query is trashed. (ACTIVE, DELETED) |
parent_path | string | The workspace path of the folder containing the alert. Can only be set on create, and cannot be updated. |
query_text | string | Text of the query to be run. |
run_as | object | Specifies 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. |
schedule | object | |
update_time | string | The timestamp indicating when the alert was updated. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | id, deployment_name | Gets an alert. | |
list | select | deployment_name | page_size, page_token | Gets a list of alerts accessible to the user, ordered by creation time. |
create | insert | deployment_name, alert | Create Alert | |
update | update | id, update_mask, deployment_name, alert | Update alert | |
delete | delete | id, deployment_name | purge | Moves 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.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
id | string | :param purge: bool (optional) Whether to permanently delete the alert. If not set, the alert will only be soft deleted. |
update_mask | string | |
page_size | integer | :param page_token: str (optional) |
page_token | string | |
purge | boolean |
SELECT examples
- get
- list
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
;
Gets a list of alerts accessible to the user, ordered by creation time.
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 deployment_name = '{{ deployment_name }}' -- required
AND page_size = '{{ page_size }}'
AND page_token = '{{ page_token }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: alerts_v2
props:
- name: deployment_name
value: "{{ deployment_name }}"
description: Required parameter for the alerts_v2 resource.
- name: alert
description: |
:returns: :class:`AlertV2`
value:
display_name: "{{ display_name }}"
query_text: "{{ query_text }}"
warehouse_id: "{{ warehouse_id }}"
evaluation:
source:
name: "{{ name }}"
aggregation: "{{ aggregation }}"
display: "{{ display }}"
comparison_operator: "{{ comparison_operator }}"
empty_result_state: "{{ empty_result_state }}"
last_evaluated_at: "{{ last_evaluated_at }}"
notification:
notify_on_ok: {{ notify_on_ok }}
retrigger_seconds: {{ retrigger_seconds }}
subscriptions:
- destination_id: "{{ destination_id }}"
user_email: "{{ user_email }}"
state: "{{ state }}"
threshold:
column:
name: "{{ name }}"
aggregation: "{{ aggregation }}"
display: "{{ display }}"
value:
bool_value: {{ bool_value }}
double_value: {{ double_value }}
string_value: "{{ string_value }}"
schedule:
quartz_cron_schedule: "{{ quartz_cron_schedule }}"
timezone_id: "{{ timezone_id }}"
pause_status: "{{ pause_status }}"
create_time: "{{ create_time }}"
custom_description: "{{ custom_description }}"
custom_summary: "{{ custom_summary }}"
effective_run_as:
service_principal_name: "{{ service_principal_name }}"
user_name: "{{ user_name }}"
id: "{{ id }}"
lifecycle_state: "{{ lifecycle_state }}"
owner_user_name: "{{ owner_user_name }}"
parent_path: "{{ parent_path }}"
run_as:
service_principal_name: "{{ service_principal_name }}"
user_name: "{{ user_name }}"
run_as_user_name: "{{ run_as_user_name }}"
update_time: "{{ update_time }}"
UPDATE examples
- update
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
- delete
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 }}'
;