Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 213
Add support for .dbalert.json files#3602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6c1c7372a6023875034f1e187e23fdc778c38750028d7d38fb74d8b1bec49a50c9160c0f4ffe102cba25ee1ee53d1e03f847395a315faa0f0ef378d5a7a3529095a33383c218File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "custom_summary": "My alert from file", | ||
| "evaluation": { | ||
| "source": { | ||
| "name": "1", | ||
| "display": "1", | ||
| "aggregation": "MAX" | ||
| }, | ||
| "comparison_operator": "EQUAL", | ||
| "threshold": { | ||
| "value": { | ||
| "double_value": 2.0 | ||
| } | ||
| }, | ||
| "notification": { | ||
| "retrigger_seconds": 1, | ||
| "notify_on_ok": false | ||
| } | ||
| }, | ||
| "schedule": { | ||
| "quartz_cron_schedule": "44 19 */1 * * ?", | ||
| "timezone_id": "Europe/Amsterdam" | ||
| }, | ||
| "query_lines": [ | ||
| "select 2" | ||
| ], | ||
| "custom_description_lines": [ | ||
| "My alert from file", | ||
| "with multiple lines", | ||
| "and a third line" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| bundle: | ||
| name: alerts-with-file-$UNIQUE_NAME | ||
| resources: | ||
| alerts: | ||
| myalert: | ||
| warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID | ||
| display_name: "myalert" | ||
| file_path: ./alert.dbalert.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| >>> [CLI] bundle validate -o json | ||
| { | ||
| "custom_description": "My alert from file\nwith multiple lines\nand a third line\n", | ||
| "custom_summary": "My alert from file", | ||
| "display_name": "myalert", | ||
| "evaluation": { | ||
| "comparison_operator": "EQUAL", | ||
| "notification": { | ||
| "notify_on_ok": false, | ||
| "retrigger_seconds": 1 | ||
| }, | ||
| "source": { | ||
| "aggregation": "MAX", | ||
| "display": "1", | ||
| "name": "1" | ||
| }, | ||
| "threshold": { | ||
| "value": { | ||
| "double_value": 2 | ||
| } | ||
| } | ||
| }, | ||
| "file_path": "alert.dbalert.json", | ||
| "parent_path": "/Workspace/Users/[USERNAME]/.bundle/alerts-with-file-[UNIQUE_NAME]/default/resources", | ||
| "query_text": "select 2\n", | ||
| "schedule": { | ||
| "quartz_cron_schedule": "44 19 */1 * * ?", | ||
| "timezone_id": "Europe/Amsterdam" | ||
| }, | ||
| "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" | ||
| } | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/alerts-with-file-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| >>> [CLI] alerts-v2 get-alert [ALERT_ID] | ||
| { | ||
| "display_name": "myalert", | ||
| "lifecycle_state": "ACTIVE", | ||
| "custom_summary": "My alert from file", | ||
| "evaluation": { | ||
| "comparison_operator": "EQUAL", | ||
| "notification": { | ||
| "notify_on_ok": false, | ||
| "retrigger_seconds": 1 | ||
| }, | ||
| "source": { | ||
| "aggregation": "MAX", | ||
| "display": "1", | ||
| "name": "1" | ||
| }, | ||
| "threshold": { | ||
| "value": { | ||
| "double_value": 2 | ||
| } | ||
| } | ||
| }, | ||
| "query_text": "select 2\n", | ||
| "schedule": { | ||
| "quartz_cron_schedule": "44 19 */1 * * ?", | ||
| "timezone_id": "Europe/Amsterdam" | ||
| }, | ||
| "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" | ||
| } | ||
| === assert that the uploaded alert file is the same as the local one | ||
| >>> [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/alerts-with-file-[UNIQUE_NAME]/default/resources/myalert.dbalert.json | ||
| >>> diff exported_alert.dbalert.json alert.dbalert.json --strip-trailing-cr | ||
| >>> [CLI] alerts-v2 get-alert [ALERT_ID] | ||
| { | ||
| "display_name": "myalert", | ||
| "lifecycle_state": "ACTIVE" | ||
| } | ||
| >>> [CLI] bundle summary | ||
| Name: alerts-with-file-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/alerts-with-file-[UNIQUE_NAME]/default | ||
| Resources: | ||
| Alerts: | ||
| myalert: | ||
| Name: myalert | ||
| URL: [DATABRICKS_URL]/sql/alerts-v2/[ALERT_ID] | ||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.alerts.myalert | ||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/alerts-with-file-[UNIQUE_NAME]/default | ||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| } | ||
| trap cleanup EXIT | ||
| trace $CLI bundle validate -o json | jq .resources.alerts.myalert | ||
| trace $CLI bundle deploy | ||
| alert_id=$($CLI bundle summary --output json | jq -r '.resources.alerts.myalert.id') | ||
| echo "$alert_id:ALERT_ID" >> ACC_REPLS | ||
| trace $CLI alerts-v2 get-alert $alert_id | jq '{display_name, lifecycle_state, custom_summary, evaluation, query_text, schedule, warehouse_id}' | ||
| alert_path=$($CLI bundle summary --output json | jq -r '.resources.alerts.myalert.parent_path')/myalert.dbalert.json | ||
| title "assert that the uploaded alert file is the same as the local one" | ||
| trace $CLI workspace export $alert_path > exported_alert.dbalert.json | ||
| trace diff exported_alert.dbalert.json alert.dbalert.json --strip-trailing-cr | ||
| rm exported_alert.dbalert.json | ||
| trace $CLI alerts-v2 get-alert $alert_id | jq '{display_name, lifecycle_state}' | ||
| trace $CLI bundle summary |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Local = false | ||
| Cloud = true | ||
| RecordRequests = false | ||
| Ignore = [".databricks"] | ||
| # redact ?o=[NUMID]. Different clouds can have different URL serialization, like [DATABRICKS_URL]/sql/alerts-v2/[ALERT_ID] vs [DATABRICKS_URL]/sql/alerts-v2/[ALERT_ID]?o=[NUMID]. | ||
| [[Repls]] | ||
| Old = '\?o=\d+' | ||
| New = '' | ||
| Order = 0 | ||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] | ||
| [Env] | ||
| # MSYS2 automatically converts absolute paths like /Users/$username/$UNIQUE_NAME to | ||
| # C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI | ||
| # Setting this environment variable prevents that conversion on windows. | ||
| MSYS_NO_PATHCONV = "1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "custom_summary": "My alert from file", | ||
| "evaluation": { | ||
| "comparison_operator": "EQUAL", | ||
| "notification": { | ||
| "notify_on_ok": false, | ||
| "retrigger_seconds": 1 | ||
| }, | ||
| "source": { | ||
| "aggregation": "MAX", | ||
| "display": "1", | ||
| "name": "1" | ||
| }, | ||
| "threshold": { | ||
| "value": { | ||
| "double_value": 2 | ||
| } | ||
| } | ||
| }, | ||
| "query_lines": [ | ||
| "select 2" | ||
| ], | ||
| "custom_description_lines": [ | ||
| "My alert from file", | ||
| "with multiple lines", | ||
| "and a third line" | ||
| ], | ||
| "schedule": { | ||
| "pause_status": "UNPAUSED", | ||
| "quartz_cron_schedule": "44 19 */1 * * ?", | ||
| "timezone_id": "Europe/Amsterdam" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| bundle: | ||
| name: alerts-not-allowed-field | ||
| resources: | ||
| alerts: | ||
| myalert: | ||
| warehouse_id: "0123456789012345" | ||
| display_name: "My alert" | ||
| file_path: ./alert.dbalert.json | ||
| # This field is not allowed when file_path is specified | ||
| query_text: "select 3" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| >>> trace [CLI] bundle validate | ||
| >>> [CLI] bundle validate | ||
| Error: field query_text is not allowed in the bundle configuration. | ||
| at resources.alerts.myalert.query_text | ||
| in databricks.yml:11:19 | ||
| When a .dbalert.json is specified, only the following fields are allowed in the bundle configuration: warehouse_id, display_name, file_path, permissions, lifecycle | ||
| Name: alerts-not-allowed-field | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/alerts-not-allowed-field/default | ||
| Found 1 error | ||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| errcode trace trace $CLI bundle validate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Local = true | ||
| RecordRequests = false | ||
| Ignore = [".databricks"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "custom_summary": "Alert for ${var.target}", | ||
| "evaluation": { | ||
| "comparison_operator": "EQUAL", | ||
| "notification": { | ||
| "notify_on_ok": false, | ||
| "retrigger_seconds": 1 | ||
| }, | ||
| "source": { | ||
| "aggregation": "MAX", | ||
| "display": "1", | ||
| "name": "1" | ||
| }, | ||
| "threshold": { | ||
| "value": { | ||
| "double_value": 2 | ||
| } | ||
| } | ||
| }, | ||
| "query_lines": [ | ||
| "select 2" | ||
| ], | ||
| "custom_description_lines": [ | ||
| "Alert for ${var.target}", | ||
| "with multiple lines", | ||
| "and a third line" | ||
| ], | ||
| "schedule": { | ||
| "pause_status": "UNPAUSED", | ||
| "quartz_cron_schedule": "44 19 */1 * * ?", | ||
| "timezone_id": "Europe/Amsterdam" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| bundle: | ||
| name: alerts-variable-error | ||
| resources: | ||
| alerts: | ||
| myalert: | ||
| warehouse_id: "0123456789012345" | ||
| display_name: "My alert" | ||
| file_path: ./alert.dbalert.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| >>> [CLI] bundle validate | ||
| Error: .alert file alert.dbalert.json must not contain variable interpolations. | ||
| at resources.alerts.myalert.file_path | ||
| in databricks.yml:9:18 | ||
| Please inline the alert configuration in the bundle configuration to use variables | ||
| Name: alerts-variable-error | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/alerts-variable-error/default | ||
| Found 1 error | ||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| errcode trace $CLI bundle validate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Local = true | ||
| RecordRequests = false | ||
| Ignore = [".databricks"] |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future: We should allow override of the query text even when using a file_path, unless there will be another way to accept parameters like {catalog} and {schema} in the alert file.