|
| 1 | +{ |
| 2 | + "custom_summary": "Job Clusters EOS Alert", |
| 3 | + "evaluation": { |
| 4 | + "source": { |
| 5 | + "name": "is_supported", |
| 6 | + "display": "is_supported", |
| 7 | + "aggregation": "COUNT" |
| 8 | + }, |
| 9 | + "comparison_operator": "GREATER_THAN", |
| 10 | + "threshold": { |
| 11 | + "value": { |
| 12 | + "double_value": 0.0 |
| 13 | + } |
| 14 | + }, |
| 15 | + "empty_result_state": "OK", |
| 16 | + "notification": { |
| 17 | + "retrigger_seconds": 1, |
| 18 | + "notify_on_ok": false |
| 19 | + } |
| 20 | + }, |
| 21 | + "schedule": { |
| 22 | + "quartz_cron_schedule": "29 20 6 * * ?", |
| 23 | + "timezone_id": "America/New_York" |
| 24 | + }, |
| 25 | + "query_lines": [ |
| 26 | + "WITH", |
| 27 | + "filtered_usage AS (", |
| 28 | + " SELECT", |
| 29 | + " u.workspace_id,", |
| 30 | + " u.usage_metadata.cluster_id,", |
| 31 | + " u.usage_metadata.job_id,", |
| 32 | + " u.usage_quantity,", |
| 33 | + " u.identity_metadata.run_as,", |
| 34 | + " u.sku_name,", |
| 35 | + " u.usage_date", |
| 36 | + " FROM", |
| 37 | + " system.billing.usage u", |
| 38 | + " WHERE", |
| 39 | + " u.billing_origin_product = 'JOBS'", |
| 40 | + " AND u.usage_metadata.node_type != 'SERVERLESS'", |
| 41 | + " AND u.usage_metadata.job_id IS NOT NULL", |
| 42 | + " AND u.usage_date >= CURRENT_DATE - INTERVAL 30 DAYS", |
| 43 | + " --AND (:workspace_ids = ARRAY('All') OR array_contains(:workspace_ids, u.workspace_id))", |
| 44 | + " GROUP BY ALL", |
| 45 | + "),", |
| 46 | + "", |
| 47 | + "-- Price lookup", |
| 48 | + "price_lookup AS (", |
| 49 | + " SELECT ", |
| 50 | + " sku_name,", |
| 51 | + " pricing.effective_list.default AS price_per_dbu", |
| 52 | + " FROM system.billing.list_prices", |
| 53 | + " WHERE price_end_time IS NULL", |
| 54 | + "),", |
| 55 | + "", |
| 56 | + "-- Join with cluster and parse DBR version", |
| 57 | + "usage_with_dbr AS (", |
| 58 | + " SELECT", |
| 59 | + " fu.workspace_id,", |
| 60 | + " fu.cluster_id,", |
| 61 | + " fu.job_id,", |
| 62 | + " fu.usage_date,", |
| 63 | + " fu.usage_quantity,", |
| 64 | + " fu.run_as,", |
| 65 | + " pl.price_per_dbu,", |
| 66 | + " NULLIF(regexp_extract(c.dbr_version, '\\\\d+\\\\.\\\\d', 0), '') AS dbr_version", |
| 67 | + " FROM", |
| 68 | + " filtered_usage fu", |
| 69 | + " JOIN system.compute.clusters c", |
| 70 | + " ON fu.cluster_id = c.cluster_id", |
| 71 | + " JOIN price_lookup pl", |
| 72 | + " ON fu.sku_name = pl.sku_name", |
| 73 | + " WHERE dbr_version IS NOT NULL", |
| 74 | + ")", |
| 75 | + "", |
| 76 | + "-- Aggregate per job", |
| 77 | + "", |
| 78 | + " SELECT", |
| 79 | + " u.workspace_id,", |
| 80 | + " u.job_id,", |
| 81 | + " u.dbr_version,", |
| 82 | + " coalesce(wn.dbr_version, u.dbr_version) as dbr_version_lts_ind,", |
| 83 | + " CASE WHEN wn.end_of_support_date IS NOT NULL THEN datediff(wn.end_of_support_date, current_date) ELSE 0 END AS days_till_eos, --days till end of support", |
| 84 | + " max(u.usage_date) as latest_usage_date,", |
| 85 | + " ARRAY_AGG(DISTINCT u.run_as) AS run_identities,", |
| 86 | + " MAX(CASE", |
| 87 | + " WHEN wn.end_of_support_date IS NOT NULL AND CURRENT_DATE <= wn.end_of_support_date THEN TRUE", |
| 88 | + " ELSE FALSE", |
| 89 | + " END) AS is_supported", |
| 90 | + " FROM", |
| 91 | + " usage_with_dbr u", |
| 92 | + " LEFT JOIN dbdemos.lookup.dbr_version wn ", |
| 93 | + " ON u.dbr_version = wn.clean_dbr_version", |
| 94 | + " GROUP BY", |
| 95 | + " u.workspace_id, u.job_id, u.dbr_version, dbr_version_lts_ind, days_till_eos", |
| 96 | + "HAVING is_supported = false" |
| 97 | + ], |
| 98 | + "custom_description_lines": [ |
| 99 | + "Alert \"{{ALERT_NAME}}\" changed status to {{ALERT_STATUS}}.<br>", |
| 100 | + "We recommend upgrading all clusters running DBR that are nearing or past the end of service to serverless. <br>", |
| 101 | + "Serverless clusters automatically manage DBR for you, ensuring they are supported.<br>", |
| 102 | + "Query result value: {{QUERY_RESULT_VALUE}}<br>", |
| 103 | + "<a href=\"{{ALERT_URL}}\">Go to alert</a> | ", |
| 104 | + "<a href=\"{{DASHBOARD_URL}}\">Go to dashboard</a>" |
| 105 | + ] |
| 106 | +} |
0 commit comments