監視無伺服器計算的成本
重要
公開預覽版中筆記本和工作流程的無伺服器計算。 如需資格和啟用的相關信息,請參閱 啟用無伺服器計算公開預覽。
本文說明如何使用計費使用量系統數據表 (Public Preview) 來監視無伺服器計算使用量的成本。
您可以查詢計費使用量系統數據表 ,system.billing.usage
其中包含與無伺服器計算成本相關的使用者和工作負載屬性,以監視筆記本和工作流程的無伺服器計算使用量。 適用的欄位包括:
- 數據
identity_metadata
行包含run_as
欄位,其中顯示用來執行工作負載之認證的用戶或服務主體。 - 資料
usage_metadata
列具有描述工作負載的欄位:job_run_id
和notebook_id
。
無伺服器使用量記錄的考慮
分析無伺服器使用量時,請考慮下列事項:
- 您可能會在指定小時內看到與指定無伺服器計算工作負載相關聯的多個記錄。 例如,您可能會看到多個記錄具有相同
job_id
,job_run_id
但每個記錄都有不同的 DBU 耗用量值。 這些 DBU 的總和共同代表指定作業執行的每小時 DBU 耗用量。 - 您也可以看到使用無伺服器 SKU 計費 DBU 耗用量的記錄,但針對 、
job_id
、job_run_id
和notebook_id
使用 Null 值run_as
。 這些代表與未直接歸屬於任何特定工作負載的共用資源相關聯的成本。 當您增加無伺服器計算的使用方式並新增更多工作負載時,帳單上這些共用成本的比例將會隨著更多工作負載的共用而減少。
成本可觀察性儀錶板
若要協助您開始監視無伺服器成本,請從 Github 下載下列成本可檢視性儀錶板。 請參閱 無伺服器成本可檢視性儀錶板。
下載 JSON 檔案之後,請將儀錶板匯入工作區。 如需匯入儀錶板的指示,請參閱 匯入儀錶板檔案。
使用警示來追蹤無伺服器支出
警示是讓您隨時掌握無伺服器費用的強大方式。 透過警示,您可以在查詢結果中符合特定條件時收到通知。 若要瞭解如何建立警示,請參閱 建立警示。
您可以將警示新增至下列查詢,以監視預算。 在每個查詢中,將 取代 {budget}
為您所選擇的預算。
過去 30 天內任何工作區支出超過閾值時發出警示
每當此查詢傳回資料列時,您可以設定要觸發的警示。 以您選擇的預算取代 {budget}
。
SELECT
t1.workspace_id,
SUM(t1.usage_quantity * list_prices.pricing.default) as list_cost
FROM system.billing.usage t1
INNER JOIN system.billing.list_prices on
t1.cloud = list_prices.cloud and
t1.sku_name = list_prices.sku_name and
t1.usage_start_time >= list_prices.price_start_time and
(t1.usage_end_time <= list_prices.price_end_time or list_prices.price_end_time is null)
WHERE
t1.sku_name LIKE '%SERVERLESS%'
AND billing_origin_product IN ("JOBS", "NOTEBOOKS")
AND t1.usage_date >= CURRENT_DATE() - INTERVAL 30 DAYS
GROUP BY
t1.workspace_id
HAVING
list_cost > {budget}
當使用者在過去 30 天內超過閾值時發出警示
每當此查詢傳回資料列時,您可以設定要觸發的警示。 以您選擇的預算取代 {budget}
。
SELECT
t1.identity_metadata.run_as,
SUM(t1.usage_quantity * list_prices.pricing.default) as list_cost
FROM system.billing.usage t1
INNER JOIN system.billing.list_prices on
t1.cloud = list_prices.cloud and
t1.sku_name = list_prices.sku_name and
t1.usage_start_time >= list_prices.price_start_time and
(t1.usage_end_time <= list_prices.price_end_time or list_prices.price_end_time is null)
WHERE
t1.sku_name LIKE '%SERVERLESS%'
AND billing_origin_product IN ("JOBS", "NOTEBOOKS")
AND t1.usage_date >= CURRENT_DATE() - INTERVAL 30 DAYS
GROUP BY
t1.identity_metadata.run_as
HAVING
list_cost > {budget}
當作業在過去 30 天內超過閾值時發出警示
每當此查詢傳回資料列時,您可以設定要觸發的警示。 以您選擇的預算取代 {budget}
。
SELECT
t1.workspace_id,
t1.usage_metadata.job_id,
SUM(t1.usage_quantity * list_prices.pricing.default) as list_cost
FROM system.billing.usage t1
INNER JOIN system.billing.list_prices on
t1.cloud = list_prices.cloud and
t1.sku_name = list_prices.sku_name and
t1.usage_start_time >= list_prices.price_start_time and
(t1.usage_end_time <= list_prices.price_end_time or list_prices.price_end_time is null)
WHERE
t1.sku_name LIKE '%SERVERLESS%'
AND billing_origin_product IN ("JOBS")
AND t1.usage_date >= CURRENT_DATE() - INTERVAL 30 DAYS
GROUP BY
t1.workspace_id, t1.usage_metadata.job_id,
HAVING
list_cost > {budget}
範例查詢
使用下列查詢來深入瞭解您帳戶中的無伺服器使用量:
識別昂貴的無伺服器計算筆記本
此查詢會傳回筆記本清單,以及 DBU 耗用量以遞減順序取用每個筆記本的 DBU 數目:
SELECT
usage_metadata.notebook_id,
SUM(usage_quantity) as total_dbu
FROM
system.billing.usage
WHERE
usage_metadata.notebook_id is not null
and billing_origin_product = 'INTERACTIVE'
and product_features.is_serverless
and usage_unit = 'DBU'
and usage_date >= DATEADD(day, -30, current_date)
GROUP BY
1
ORDER BY
total_dbu DESC
識別昂貴的無伺服器計算作業
此查詢會傳回作業清單,以及 DBU 耗用量以遞減順序取用每個作業的 DBU 數目:
SELECT
usage_metadata.job_id,
SUM(usage_quantity) as total_dbu
FROM
system.billing.usage
WHERE
usage_metadata.job_id is not null
and billing_origin_product = 'JOBS'
and product_features.is_serverless
and usage_unit = 'DBU'
and usage_date >= DATEADD(day, -30, current_date)
GROUP BY
1
ORDER BY
total_dbu DESC
報告特定使用者所取用的 DBU
此查詢會傳回使用特定使用者或服務主體所執行無伺服器計算的筆記本和作業清單,以及每個工作負載所取用的 DBU 數目:
SELECT
usage_metadata.job_id,
usage_metadata.notebook_id,
SUM(usage_quantity) as total_dbu
FROM
system.billing.usage
WHERE
identity_metadata.run_as = '<emailaddress@domain.com>'
and billing_origin_product in ('JOBS','INTERACTIVE')
and product_features.is_serverless
and usage_unit = 'DBU'
and usage_date >= DATEADD(day, -30, current_date)
GROUP BY
1,2
ORDER BY
total_dbu DESC
在共用自定義標籤的工作負載所耗用的無伺服器計算 DBU 上報告
此查詢會傳回一份工作清單,這些作業會使用共用相同自定義標籤的無伺服器計算,以及每個工作負載所耗用的 DBU 數目:
SELECT
usage_metadata.job_id,
usage_metadata.notebook_id,
SUM(usage_quantity) as total_dbu
FROM
system.billing.usage
WHERE
custom_tags.<key> = '<value>'
and billing_origin_product in ('JOBS','INTERACTIVE')
and product_features.is_serverless
and usage_unit = 'DBU'
and usage_date >= DATEADD(day, -30, current_date)
GROUP BY
1,2
ORDER BY
total_dbu DESC
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應