Skip to content

Commit d7d25d5

Browse files
Add example for refering to a file in alerts (#142)
This PR documents the second way to refer to alerts in DABs. Both alerts have identical configurations and are in the same example to make it clear that either mode is acceptable to use. Tested using `databricks bundle validate` that this example works.
1 parent fa12c08 commit d7d25d5

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

knowledge_base/alerts/resources/nyc_taxi_daily_revenue.alert.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,16 @@ resources:
4848
pause_status: "UNPAUSED"
4949
quartz_cron_schedule: "0 0 8 * * ?" # Run daily at 8 AM UTC
5050
timezone_id: "UTC"
51+
52+
# This alert is configured identically to the above alert, but it refers to a .dbalert.json file
53+
# instead of inlining the configuration in YAML. We recommend inlining the configuration in YAML
54+
# when you need to productionize the alert across different target (dev, staging, prod) and
55+
# using a .dbalert.json file when you have a single target alert that you author in the Databricks UI
56+
# or using the databricks bundle generate alert command.
57+
nyc_taxi_daily_revenue_as_file:
58+
permissions:
59+
- level: CAN_MANAGE
60+
user_name: user@company.com
61+
display_name: "NYC Taxi Daily Revenue Alert as File"
62+
warehouse_id: ${var.warehouse_id}
63+
file_path: ./nyc_taxi_daily_revenue_as_file.dbalert.json
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"custom_summary": "Alert when NYC Taxi daily revenue exceeds threshold",
3+
"evaluation": {
4+
"source": {
5+
"name": "amount",
6+
"display": "amount",
7+
"aggregation": "MAX"
8+
},
9+
"comparison_operator": "GREATER_THAN",
10+
"threshold": {
11+
"value": {
12+
"double_value": 1000000.0
13+
}
14+
},
15+
"notification": {
16+
"retrigger_seconds": 3600,
17+
"notify_on_ok": false
18+
}
19+
},
20+
"schedule": {
21+
"quartz_cron_schedule": "0 0 8 * * ?",
22+
"timezone_id": "UTC"
23+
},
24+
"query_lines": [
25+
"SELECT",
26+
" to_date(tpep_pickup_datetime) as date,",
27+
" SUM(fare_amount) as amount",
28+
"FROM",
29+
" `samples`.`nyctaxi`.`trips`",
30+
"GROUP BY",
31+
" ALL",
32+
"ORDER BY",
33+
" 1 DESC"
34+
]
35+
}

0 commit comments

Comments
 (0)