databricks.SqlAlert
Explore with Pulumi AI
This resource allows you to manage Databricks SQL Alerts.
To manage SQLA resources you must have
databricks_sql_access
on your databricks.Group or databricks_user.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
const sharedDir = new databricks.Directory("shared_dir", {path: "/Shared/Queries"});
const _this = new databricks.SqlQuery("this", {
dataSourceId: example.dataSourceId,
name: "My Query Name",
query: "SELECT 1 AS p1, 2 as p2",
parent: pulumi.interpolate`folders/${sharedDir.objectId}`,
});
const alert = new databricks.SqlAlert("alert", {
queryId: _this.id,
name: "My Alert",
parent: pulumi.interpolate`folders/${sharedDir.objectId}`,
rearm: 1,
options: {
column: "p1",
op: "==",
value: "2",
muted: false,
},
});
import pulumi
import pulumi_databricks as databricks
shared_dir = databricks.Directory("shared_dir", path="/Shared/Queries")
this = databricks.SqlQuery("this",
data_source_id=example["dataSourceId"],
name="My Query Name",
query="SELECT 1 AS p1, 2 as p2",
parent=shared_dir.object_id.apply(lambda object_id: f"folders/{object_id}"))
alert = databricks.SqlAlert("alert",
query_id=this.id,
name="My Alert",
parent=shared_dir.object_id.apply(lambda object_id: f"folders/{object_id}"),
rearm=1,
options={
"column": "p1",
"op": "==",
"value": "2",
"muted": False,
})
package main
import (
"fmt"
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
sharedDir, err := databricks.NewDirectory(ctx, "shared_dir", &databricks.DirectoryArgs{
Path: pulumi.String("/Shared/Queries"),
})
if err != nil {
return err
}
this, err := databricks.NewSqlQuery(ctx, "this", &databricks.SqlQueryArgs{
DataSourceId: pulumi.Any(example.DataSourceId),
Name: pulumi.String("My Query Name"),
Query: pulumi.String("SELECT 1 AS p1, 2 as p2"),
Parent: sharedDir.ObjectId.ApplyT(func(objectId int) (string, error) {
return fmt.Sprintf("folders/%v", objectId), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
_, err = databricks.NewSqlAlert(ctx, "alert", &databricks.SqlAlertArgs{
QueryId: this.ID(),
Name: pulumi.String("My Alert"),
Parent: sharedDir.ObjectId.ApplyT(func(objectId int) (string, error) {
return fmt.Sprintf("folders/%v", objectId), nil
}).(pulumi.StringOutput),
Rearm: pulumi.Int(1),
Options: &databricks.SqlAlertOptionsArgs{
Column: pulumi.String("p1"),
Op: pulumi.String("=="),
Value: pulumi.String("2"),
Muted: pulumi.Bool(false),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
var sharedDir = new Databricks.Directory("shared_dir", new()
{
Path = "/Shared/Queries",
});
var @this = new Databricks.SqlQuery("this", new()
{
DataSourceId = example.DataSourceId,
Name = "My Query Name",
Query = "SELECT 1 AS p1, 2 as p2",
Parent = sharedDir.ObjectId.Apply(objectId => $"folders/{objectId}"),
});
var alert = new Databricks.SqlAlert("alert", new()
{
QueryId = @this.Id,
Name = "My Alert",
Parent = sharedDir.ObjectId.Apply(objectId => $"folders/{objectId}"),
Rearm = 1,
Options = new Databricks.Inputs.SqlAlertOptionsArgs
{
Column = "p1",
Op = "==",
Value = "2",
Muted = false,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.Directory;
import com.pulumi.databricks.DirectoryArgs;
import com.pulumi.databricks.SqlQuery;
import com.pulumi.databricks.SqlQueryArgs;
import com.pulumi.databricks.SqlAlert;
import com.pulumi.databricks.SqlAlertArgs;
import com.pulumi.databricks.inputs.SqlAlertOptionsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var sharedDir = new Directory("sharedDir", DirectoryArgs.builder()
.path("/Shared/Queries")
.build());
var this_ = new SqlQuery("this", SqlQueryArgs.builder()
.dataSourceId(example.dataSourceId())
.name("My Query Name")
.query("SELECT 1 AS p1, 2 as p2")
.parent(sharedDir.objectId().applyValue(objectId -> String.format("folders/%s", objectId)))
.build());
var alert = new SqlAlert("alert", SqlAlertArgs.builder()
.queryId(this_.id())
.name("My Alert")
.parent(sharedDir.objectId().applyValue(objectId -> String.format("folders/%s", objectId)))
.rearm(1)
.options(SqlAlertOptionsArgs.builder()
.column("p1")
.op("==")
.value("2")
.muted(false)
.build())
.build());
}
}
resources:
sharedDir:
type: databricks:Directory
name: shared_dir
properties:
path: /Shared/Queries
this:
type: databricks:SqlQuery
properties:
dataSourceId: ${example.dataSourceId}
name: My Query Name
query: SELECT 1 AS p1, 2 as p2
parent: folders/${sharedDir.objectId}
alert:
type: databricks:SqlAlert
properties:
queryId: ${this.id}
name: My Alert
parent: folders/${sharedDir.objectId}
rearm: 1
options:
column: p1
op: ==
value: '2'
muted: false
Access Control
databricks.Permissions can control which groups or individual users can Manage, Edit, Run or View individual alerts.
Related Resources
The following resources are often used in the same context:
- End to end workspace management guide.
- databricks.SqlQuery to manage Databricks SQL Queries.
- databricks.SqlEndpoint to manage Databricks SQL Endpoints.
- databricks.Directory to manage directories in Databricks Workpace.
Create SqlAlert Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SqlAlert(name: string, args: SqlAlertArgs, opts?: CustomResourceOptions);
@overload
def SqlAlert(resource_name: str,
args: SqlAlertArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SqlAlert(resource_name: str,
opts: Optional[ResourceOptions] = None,
options: Optional[SqlAlertOptionsArgs] = None,
query_id: Optional[str] = None,
created_at: Optional[str] = None,
name: Optional[str] = None,
parent: Optional[str] = None,
rearm: Optional[int] = None,
updated_at: Optional[str] = None)
func NewSqlAlert(ctx *Context, name string, args SqlAlertArgs, opts ...ResourceOption) (*SqlAlert, error)
public SqlAlert(string name, SqlAlertArgs args, CustomResourceOptions? opts = null)
public SqlAlert(String name, SqlAlertArgs args)
public SqlAlert(String name, SqlAlertArgs args, CustomResourceOptions options)
type: databricks:SqlAlert
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SqlAlertArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SqlAlertArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SqlAlertArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SqlAlertArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SqlAlertArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var sqlAlertResource = new Databricks.SqlAlert("sqlAlertResource", new()
{
Options = new Databricks.Inputs.SqlAlertOptionsArgs
{
Column = "string",
Op = "string",
Value = "string",
CustomBody = "string",
CustomSubject = "string",
EmptyResultState = "string",
Muted = false,
},
QueryId = "string",
CreatedAt = "string",
Name = "string",
Parent = "string",
Rearm = 0,
UpdatedAt = "string",
});
example, err := databricks.NewSqlAlert(ctx, "sqlAlertResource", &databricks.SqlAlertArgs{
Options: &databricks.SqlAlertOptionsArgs{
Column: pulumi.String("string"),
Op: pulumi.String("string"),
Value: pulumi.String("string"),
CustomBody: pulumi.String("string"),
CustomSubject: pulumi.String("string"),
EmptyResultState: pulumi.String("string"),
Muted: pulumi.Bool(false),
},
QueryId: pulumi.String("string"),
CreatedAt: pulumi.String("string"),
Name: pulumi.String("string"),
Parent: pulumi.String("string"),
Rearm: pulumi.Int(0),
UpdatedAt: pulumi.String("string"),
})
var sqlAlertResource = new SqlAlert("sqlAlertResource", SqlAlertArgs.builder()
.options(SqlAlertOptionsArgs.builder()
.column("string")
.op("string")
.value("string")
.customBody("string")
.customSubject("string")
.emptyResultState("string")
.muted(false)
.build())
.queryId("string")
.createdAt("string")
.name("string")
.parent("string")
.rearm(0)
.updatedAt("string")
.build());
sql_alert_resource = databricks.SqlAlert("sqlAlertResource",
options={
"column": "string",
"op": "string",
"value": "string",
"custom_body": "string",
"custom_subject": "string",
"empty_result_state": "string",
"muted": False,
},
query_id="string",
created_at="string",
name="string",
parent="string",
rearm=0,
updated_at="string")
const sqlAlertResource = new databricks.SqlAlert("sqlAlertResource", {
options: {
column: "string",
op: "string",
value: "string",
customBody: "string",
customSubject: "string",
emptyResultState: "string",
muted: false,
},
queryId: "string",
createdAt: "string",
name: "string",
parent: "string",
rearm: 0,
updatedAt: "string",
});
type: databricks:SqlAlert
properties:
createdAt: string
name: string
options:
column: string
customBody: string
customSubject: string
emptyResultState: string
muted: false
op: string
value: string
parent: string
queryId: string
rearm: 0
updatedAt: string
SqlAlert Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The SqlAlert resource accepts the following input properties:
- Options
Sql
Alert Options - Alert configuration options.
- Query
Id string - ID of the query evaluated by the alert.
- Created
At string - Name string
- Name of the alert.
- Parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - Rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- Updated
At string
- Options
Sql
Alert Options Args - Alert configuration options.
- Query
Id string - ID of the query evaluated by the alert.
- Created
At string - Name string
- Name of the alert.
- Parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - Rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- Updated
At string
- options
Sql
Alert Options - Alert configuration options.
- query
Id String - ID of the query evaluated by the alert.
- created
At String - name String
- Name of the alert.
- parent String
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - rearm Integer
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At String
- options
Sql
Alert Options - Alert configuration options.
- query
Id string - ID of the query evaluated by the alert.
- created
At string - name string
- Name of the alert.
- parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - rearm number
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At string
- options
Sql
Alert Options Args - Alert configuration options.
- query_
id str - ID of the query evaluated by the alert.
- created_
at str - name str
- Name of the alert.
- parent str
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated_
at str
- options Property Map
- Alert configuration options.
- query
Id String - ID of the query evaluated by the alert.
- created
At String - name String
- Name of the alert.
- parent String
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - rearm Number
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At String
Outputs
All input properties are implicitly available as output properties. Additionally, the SqlAlert resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing SqlAlert Resource
Get an existing SqlAlert resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SqlAlertState, opts?: CustomResourceOptions): SqlAlert
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
created_at: Optional[str] = None,
name: Optional[str] = None,
options: Optional[SqlAlertOptionsArgs] = None,
parent: Optional[str] = None,
query_id: Optional[str] = None,
rearm: Optional[int] = None,
updated_at: Optional[str] = None) -> SqlAlert
func GetSqlAlert(ctx *Context, name string, id IDInput, state *SqlAlertState, opts ...ResourceOption) (*SqlAlert, error)
public static SqlAlert Get(string name, Input<string> id, SqlAlertState? state, CustomResourceOptions? opts = null)
public static SqlAlert get(String name, Output<String> id, SqlAlertState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Created
At string - Name string
- Name of the alert.
- Options
Sql
Alert Options - Alert configuration options.
- Parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - Query
Id string - ID of the query evaluated by the alert.
- Rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- Updated
At string
- Created
At string - Name string
- Name of the alert.
- Options
Sql
Alert Options Args - Alert configuration options.
- Parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - Query
Id string - ID of the query evaluated by the alert.
- Rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- Updated
At string
- created
At String - name String
- Name of the alert.
- options
Sql
Alert Options - Alert configuration options.
- parent String
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - query
Id String - ID of the query evaluated by the alert.
- rearm Integer
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At String
- created
At string - name string
- Name of the alert.
- options
Sql
Alert Options - Alert configuration options.
- parent string
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - query
Id string - ID of the query evaluated by the alert.
- rearm number
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At string
- created_
at str - name str
- Name of the alert.
- options
Sql
Alert Options Args - Alert configuration options.
- parent str
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - query_
id str - ID of the query evaluated by the alert.
- rearm int
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated_
at str
- created
At String - name String
- Name of the alert.
- options Property Map
- Alert configuration options.
- parent String
- The identifier of the workspace folder containing the alert. The default is ther user's home folder. The folder identifier is formatted as
folder/<folder_id>
. - query
Id String - ID of the query evaluated by the alert.
- rearm Number
- Number of seconds after being triggered before the alert rearms itself and can be triggered again. If not defined, alert will never be triggered again.
- updated
At String
Supporting Types
SqlAlertOptions, SqlAlertOptionsArgs
- Column string
- Name of column in the query result to compare in alert evaluation.
- Op string
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - Value string
- Value used to compare in alert evaluation.
- Custom
Body string - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- Custom
Subject string - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- Empty
Result stringState - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - Muted bool
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
- Column string
- Name of column in the query result to compare in alert evaluation.
- Op string
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - Value string
- Value used to compare in alert evaluation.
- Custom
Body string - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- Custom
Subject string - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- Empty
Result stringState - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - Muted bool
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
- column String
- Name of column in the query result to compare in alert evaluation.
- op String
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - value String
- Value used to compare in alert evaluation.
- custom
Body String - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- custom
Subject String - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- empty
Result StringState - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - muted Boolean
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
- column string
- Name of column in the query result to compare in alert evaluation.
- op string
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - value string
- Value used to compare in alert evaluation.
- custom
Body string - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- custom
Subject string - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- empty
Result stringState - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - muted boolean
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
- column str
- Name of column in the query result to compare in alert evaluation.
- op str
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - value str
- Value used to compare in alert evaluation.
- custom_
body str - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- custom_
subject str - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- empty_
result_ strstate - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - muted bool
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
- column String
- Name of column in the query result to compare in alert evaluation.
- op String
- Operator used to compare in alert evaluation. (Enum:
>
,>=
,<
,<=
,==
,!=
) - value String
- Value used to compare in alert evaluation.
- custom
Body String - Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
- custom
Subject String - Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
- empty
Result StringState - State that alert evaluates to when query result is empty. Currently supported values are
unknown
,triggered
,ok
- check API documentation for full list of supported values. - muted Boolean
- Whether or not the alert is muted. If an alert is muted, it will not notify users and alert destinations when triggered.
Import
This resource can be imported using alert ID:
bash
$ pulumi import databricks:index/sqlAlert:SqlAlert this <alert-id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- databricks pulumi/pulumi-databricks
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
databricks
Terraform Provider.