This article explains how to use the billable usage system table to monitor the cost of your serverless compute usage.
You can monitor the usage of serverless compute for notebooks and jobs by querying the billable usage system table (system.billing.usage
), which includes user and workload attributes related to serverless compute costs. The applicable fields include:
identity_metadata
column includes the run_as
field, which shows the user or service principal whose credentials were used to run the workload.usage_metadata
column has fields that describe the workload: job_run_id
, job_name
, notebook_id
, and notebook_path
.custom_tags
column, which will include any tags inherited from serverless budget policies. See Attribute usage with serverless budget policies.There are multiple Databricks features that leverage serverless compute in the background but don't require your account to be enabled for serverless compute for notebooks, workflows, and Lakeflow Declarative Pipelines.
The following features are billed under the serverless jobs SKU:
billing_origin_product
value of LAKEHOUSE_MONITORING
.billing_origin_product
value of PREDICTIVE_OPTIMIZATION
.billing_origin_product = 'SQL'
and usage_metadata.dlt_pipeline_id IS NOT NULL
.billing_origin_product
value of FINE_GRAINED_ACCESS_CONTROL
.usage_metadata.central_clean_room_id
.When analyzing your serverless usage, consider the following:
job_id
, job_run_id
, or job_name
but with different DBU consumption values for each. The sum of these DBUs collectively represents the hourly DBU consumption for a given job run.Account admins can set up budgets to group costs and set up alerts. See Create and monitor budgets.
Import a usage dashboardâAccount admins can import cost management dashboards to any Unity Catalog-enabled workspace in their account. See Import a usage dashboard.
Find a job or notebook in the UIâTo find a job or notebook in the UI based on a billing record, copy the usage_metadata.job_id
or usage_metadata.notebook_id
value from the usage record. These IDs are immutable and can be used even if the job name or notebook path changes.
To find a job in the UI based on its job_id
:
job_id
from the usage record. For this example, assume the ID is 700809544510906
.To find a notebook in the UI based on its notebook_id
, use the following instructions:
notebook_id
from the usage record. For this example, assume the ID is 700809544510906
.https://<account-console-url>/?o=<workspace ID>#notebook/<notebook ID>/command/<command ID>
.https://<account-console-url>/?o=<workspace ID>#notebook/700809544510906
.Alerts are a powerful way to stay informed about your serverless spend. With alerts, you can receive notifications when certain conditions are met in your query results. To learn how to create alerts, see Create an alert.
You can add alerts to the following queries to monitor budgets. In each query, replace {budget}
with your chosen budget.
You can set an alert to trigger whenever this query returns a row. Replace {budget}
with your chosen budget.
SQL
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", "INTERACTIVE")
AND t1.usage_date >= CURRENT_DATE() - INTERVAL 30 DAYS
GROUP BY
t1.workspace_id
HAVING
list_cost > {budget}
Alert when a user exceeds the threshold in the last 30 daysâ
You can set an alert to trigger whenever this query returns a row. Replace {budget}
with your chosen budget.
SQL
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", "INTERACTIVE")
AND t1.usage_date >= CURRENT_DATE() - INTERVAL 30 DAYS
GROUP BY
t1.identity_metadata.run_as
HAVING
list_cost > {budget}
Alert when a job exceeds the threshold in the last 30 daysâ
You can set an alert to trigger whenever this query returns a row. Replace {budget}
with your chosen budget.
SQL
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}
Sample queriesâ
Use the following queries to gain insights into serverless usage in your account:
This query returns a list of notebooks and how many DBUs each notebook consumed, in descending order by DBU consumption:
SQL
SELECT
usage_metadata.notebook_id,
usage_metadata. notebook_path,
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,2
ORDER BY
total_dbu DESC
Sort serverless jobs based on total spendâ
This query returns a list of jobs and how many DBUs each job consumed, in descending order by DBU consumption:
SQL
SELECT
usage_metadata.job_id,
usage_metadata.job_name,
SUM(usage_quantity) as total_dbu
FROM
system.billing.usage
WHERE
usage_metadata.job_id is not null
and usage_unit = 'DBU'
and usage_date >= DATEADD(day, -30, current_date)
and sku_name like '%JOBS_SERVERLESS_COMPUTE%'
GROUP BY
1,2
ORDER BY
total_dbu DESC
Report on DBUs consumed by a particular userâ
This query returns a list of notebooks and jobs that use serverless compute run by a particular user or service principal, and the number of DBUs consumed by each workload:
SQL
SELECT
usage_metadata.job_id,
usage_metadata.job_name,
usage_metadata.notebook_id,
usage_metadata. notebook_path,
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,3,4
ORDER BY
total_dbu DESC
This query returns a list of jobs that use serverless compute that share the same custom tag, and the number of DBUs consumed by each workload:
SQL
SELECT
usage_metadata.job_id,
usage_metadata.job_name,
usage_metadata.notebook_id,
usage_metadata. notebook_path,
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,3,4
ORDER BY
total_dbu DESC
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4