Skip to content

AlertV2

laktory.models.resources.databricks.AlertV2 ¤

Bases: AlertV2Base

Databricks SQL Alert (v2)

Scheduled SQL alert evaluating its own query text, with notifications sent when a condition is met. Latest version of the SQL alerts API; Alert manages alerts of the previous API.

Examples:

import io

from laktory import models

alert_yaml = '''
display_name: high-stock-price
parent_path: /alerts
warehouse_id: a7d9f2kl8mp3q6rt
query_text: SELECT MAX(close) AS max_close FROM dev.finance.slv_stock_prices
evaluation:
  comparison_operator: GREATER_THAN
  source:
    name: max_close
  threshold:
    value:
      double_value: 500.0
  notification:
    subscriptions:
    - user_email: finance-alerts@okube.ai
schedule:
  quartz_cron_schedule: 0 0 8 * * ?
  timezone_id: America/Montreal
access_controls:
- group_name: account users
  permission_level: CAN_READ
'''
alert = models.resources.databricks.AlertV2.model_validate_yaml(
    io.StringIO(alert_yaml)
)
print(alert.parent_path)
# > /Workspace/.laktory/alerts
References
BASE DESCRIPTION
custom_description

Custom description for the alert. support mustache template

TYPE: str | None | VariableType DEFAULT: None

custom_summary

Custom summary for the alert. support mustache template

TYPE: str | None | VariableType DEFAULT: None

display_name

The display name of the alert * evaluation (AlertV2Evaluation, required)

TYPE: str | VariableType

evaluation

TYPE: AlertV2Evaluation | None | VariableType DEFAULT: None

parameters

A list of parameters to pass into the alert SQL query statement containing parameter markers. Static values only

TYPE: list[AlertV2Parameters] | None | VariableType DEFAULT: None

provider_config

Configure the provider for management through account provider

TYPE: AlertV2ProviderConfig | None | VariableType DEFAULT: None

purge_on_delete

Whether to permanently delete the alert. If not set, the alert will only be soft deleted

TYPE: bool | None | VariableType DEFAULT: None

query_text

Text of the query to be run * schedule (CronSchedule, required)

TYPE: str | VariableType

run_as

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

TYPE: AlertV2RunAs | None | VariableType DEFAULT: None

run_as_user_name

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

TYPE: str | None | VariableType DEFAULT: None

schedule

TYPE: AlertV2Schedule | None | VariableType DEFAULT: None

warehouse_id

ID of the SQL warehouse attached to the alert

TYPE: str | VariableType

LAKTORY DESCRIPTION
access_controls

SQL Alert access controls

TYPE: list[AccessControl | VariableType] | VariableType DEFAULT: []

name_prefix

Prefix added to the alert display name

TYPE: str | VariableType DEFAULT: None

name_suffix

Suffix added to the alert display name

TYPE: str | VariableType DEFAULT: None

parent_path_

The path to a workspace folder (inside laktory root) containing the alert. If changed, the alert will be recreated. The folder must exist, e.g. created by a Directory or a workspace file of the stack.

TYPE: str | None | VariableType DEFAULT: None

ATTRIBUTE DESCRIPTION
additional_core_resources
  • permissions

TYPE: list

additional_core_resources property ¤

  • permissions

laktory.models.resources.databricks.alertv2.AlertV2Evaluation ¤

Bases: BaseModel

PARAMETER DESCRIPTION
comparison_operator

Operator used for comparison in alert evaluation. Possible values are: EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL, IS_NOT_NULL, IS_NULL, LESS_THAN, LESS_THAN_OR_EQUAL, NOT_EQUAL

TYPE: str | VariableType

empty_result_state

Alert state if result is empty. Please avoid setting this field to be UNKNOWN because UNKNOWN state is planned to be deprecated. Possible values are: ERROR, OK, TRIGGERED, UNKNOWN

TYPE: str | None | VariableType DEFAULT: None

notification

User or Notification Destination to notify when alert is triggered

TYPE: AlertV2EvaluationNotification | None | VariableType DEFAULT: None

source

Source column from result to use to evaluate alert

TYPE: AlertV2EvaluationSource | None | VariableType DEFAULT: None

threshold

Threshold to user for alert evaluation, can be a column or a value

TYPE: AlertV2EvaluationThreshold | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2EvaluationNotification ¤

Bases: BaseModel

PARAMETER DESCRIPTION
notify_on_ok

Whether to notify alert subscribers when alert returns back to normal

TYPE: bool | None | VariableType DEFAULT: None

retrigger_seconds

Number of seconds an alert waits after being triggered before it is allowed to send another notification. If set to 0 or omitted, the alert will not send any further notifications after the first trigger Setting this value to 1 allows the alert to send a notification on every evaluation where the condition is met, effectively making it always retrigger for notification purposes * subscriptions (list of AlertV2Subscription, optional)

TYPE: int | None | VariableType DEFAULT: None

subscriptions

TYPE: list[AlertV2EvaluationNotificationSubscriptions] | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2EvaluationNotificationSubscriptions ¤

Bases: BaseModel

PARAMETER DESCRIPTION
destination_id

TYPE: str | None | VariableType DEFAULT: None

user_email

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2EvaluationSource ¤

Bases: BaseModel

PARAMETER DESCRIPTION
aggregation

If not set, the behavior is equivalent to using First row in the UI. Possible values are: AVG, COUNT, COUNT_DISTINCT, MAX, MEDIAN, MIN, STDDEV, SUM * display (string, optional)

TYPE: str | None | VariableType DEFAULT: None

display

TYPE: str | None | VariableType DEFAULT: None

name

The name of the parameter. Reference it in the query text as :name. Required, must be non-empty, and must be unique across the alert's parameters

TYPE: str | VariableType


laktory.models.resources.databricks.alertv2.AlertV2EvaluationThreshold ¤

Bases: BaseModel

PARAMETER DESCRIPTION
column

TYPE: AlertV2EvaluationThresholdColumn | None | VariableType DEFAULT: None

value

The value bound to the parameter, represented as a string. If omitted, the value is interpreted as NULL

TYPE: AlertV2EvaluationThresholdValue | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2EvaluationThresholdColumn ¤

Bases: BaseModel

PARAMETER DESCRIPTION
aggregation

If not set, the behavior is equivalent to using First row in the UI. Possible values are: AVG, COUNT, COUNT_DISTINCT, MAX, MEDIAN, MIN, STDDEV, SUM * display (string, optional)

TYPE: str | None | VariableType DEFAULT: None

display

TYPE: str | None | VariableType DEFAULT: None

name

The name of the parameter. Reference it in the query text as :name. Required, must be non-empty, and must be unique across the alert's parameters

TYPE: str | VariableType


laktory.models.resources.databricks.alertv2.AlertV2EvaluationThresholdValue ¤

Bases: BaseModel

PARAMETER DESCRIPTION
bool_value

TYPE: bool | None | VariableType DEFAULT: None

double_value

TYPE: float | None | VariableType DEFAULT: None

string_value

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2Parameters ¤

Bases: BaseModel

PARAMETER DESCRIPTION
name

The name of the parameter. Reference it in the query text as :name. Required, must be non-empty, and must be unique across the alert's parameters

TYPE: str | VariableType

type

The SQL data type of the parameter, for example STRING, INT, or DECIMAL(10, 2). If no type is given the type is assumed to be STRING. Complex types such as ARRAY, MAP, and STRUCT are not supported

TYPE: str | None | VariableType DEFAULT: None

value

The value bound to the parameter, represented as a string. If omitted, the value is interpreted as NULL

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2ProviderConfig ¤

Bases: BaseModel

PARAMETER DESCRIPTION
workspace_id

Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2RunAs ¤

Bases: BaseModel

PARAMETER DESCRIPTION
service_principal_name

Application ID of an active service principal. Setting this field requires the servicePrincipal/user role

TYPE: str | None | VariableType DEFAULT: None

user_name

The email of an active workspace user. Can only set this field to their own email

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.alertv2.AlertV2Schedule ¤

Bases: BaseModel

PARAMETER DESCRIPTION
pause_status

Indicate whether this schedule is paused or not. Possible values are: PAUSED, UNPAUSED

TYPE: str | None | VariableType DEFAULT: None

quartz_cron_schedule

A cron expression using quartz syntax that specifies the schedule for this pipeline. Should use the quartz format described here: http://www.quartz-scheduler.org/documentation/quartz-2.1.7/tutorials/tutorial-lesson-06.html

TYPE: str | VariableType

timezone_id

A Java timezone id. The schedule will be resolved using this timezone. This will be combined with the quartz_cron_schedule to determine the schedule. See https://docs.databricks.com/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set-timezone.html for details

TYPE: str | VariableType