CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 4 · Lesson 22/45

    Databricks system tables for cost attribution and auditing

    Use Databricks system tables (billing, compute, access, lakeflow) for cost analysis, auditing, and workload monitoring.

    19 min read
    2% of exam
    8 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Describe what system.billing.usage, system.billing.list_prices, system.compute.clusters, system.access.audit and the system.lakeflow tables record
    • Join billing usage to job runs on workspace_id, job_id and job_run_id to attribute cost to the run that produced it
    • Convert DBUs into list-price cost with system.billing.list_prices
    • Attribute all-purpose cluster spend to an owner and pick the configuration fix for idle compute
    • Build audit queries that combine action, identity and time filters

    Key concept

    System tables as a joinable operational store — System tables are read-only Delta tables in the system catalog. Databricks fills them with your account's billing, compute, job, pipeline and audit records. They share IDs such as workspace_id, cluster_id, job_id and run_id, so you answer a cost or audit question by joining a fact table like billing.usage to the dimension or timeline table that explains it.

    1.What system tables are and who can query them

    When finance asks why the bill doubled, or security asks who touched a table at 2 a.m., the answer is a SQL query against the system catalog. Databricks hosts the data there and fills it for you. Each schema covers one area: system.billing for usage and prices, system.compute for cluster configuration and node activity, system.access for audit events, and system.lakeflow for jobs and pipelines. You don't run anything to load these tables. They are free, and you pay only for the compute that runs your queries against them.

    Access works like any other Unity Catalog object. A user who is both account admin and metastore admin can read the tables by default. Anyone else needs USE CATALOG on system plus USE SCHEMA and SELECT on the schemas they query. Your workspace must be enabled for Unity Catalog to query them, but the data still includes non-Unity Catalog workspaces in the account. You can't write to the tables, and that rules out one kind of fix: you can't hide an expensive cluster by deleting its rows. The only way to change future rows is to change the resource they describe.

    The four areas this lesson uses, and the tables in each
    AreaTable pathFree retentionRegional or global
    Billingsystem.billing.usage365 daysGlobal
    Billingsystem.billing.list_pricesIndefiniteGlobal
    Computesystem.compute.clusters, system.compute.node_timeline365 days / 90 daysRegional
    Accesssystem.access.audit365 daysRegional for workspace-level events, global for account-level events
    Lakeflowsystem.lakeflow.jobs, job_tasks, job_run_timeline, job_task_run_timeline, pipelines, pipeline_update_timeline365 daysRegional

    The regional column affects what you see. A regional table only shows workspaces deployed in the same cloud region as the workspace you query from. If you need job history from a workspace in another region, you have to query from a workspace in that region. Billing is global, so you can see the whole account's spend from any region.

    Checkpoint 1 of 9· Check yourself

    An account has two Unity Catalog-enabled workspaces, one in us-east-1 and one in eu-west-1. A data engineer has the needed grants and runs queries from the us-east-1 workspace against system.billing.usage and system.lakeflow.job_run_timeline. What do the results include?

    Sources12

    2.Reading system.billing.usage

    Usage is measured in Databricks units (DBUs), the unit that system.billing.list_prices monetizes at a rate per SKU, so a row's quantity is a count of DBUs and not a dollar amount. Each row in system.billing.usage is one metered slice of consumption. usage_quantity gives the amount, usage_unit gives the unit (usually DBU), and sku_name says what kind of compute was billed, for example STANDARD_ALL_PURPOSE_COMPUTE. The row also carries workspace_id, usage_start_time/usage_end_time and a usage_date meant for fast daily aggregation. It also has billing_origin_product (such as JOBS) and the resource's custom_tags, which let you charge spend back by team or environment. Records usually arrive within 12 hours. record_type stays ORIGINAL unless Databricks later issues a correction as a retraction or restatement.

    The usage_metadata struct tells you which resource generated a row. It holds string IDs, but only the ones that apply to that compute type are filled in. The rest are null. The gaps follow fixed rules, and a cost report that ignores them will quietly lose spend.

    Which usage_metadata keys are filled for which workloads (all others are null)
    KeyFilled for
    cluster_idNon-serverless compute: notebooks, jobs, Lakeflow pipelines, legacy model serving
    job_id, job_run_idServerless jobs and jobs on job compute; not jobs on all-purpose compute
    job_nameServerless jobs and jobs on job compute (job compute since September 2025)
    warehouse_idWorkloads run on a SQL warehouse
    dlt_pipeline_id, dlt_update_idLakeflow pipelines and features built on them, such as materialized views and Lakeflow Connect
    notebook_id, notebook_pathServerless notebooks

    To scope cost to a single pipeline, filter on the matching metadata key and group by SKU and day:

    DBUs per SKU per day for one Lakeflow pipeline, filtered on usage_metadata.dlt_pipeline_idsql
    SELECT
      sku_name,
      usage_date,
      SUM(usage_quantity) AS `DBUs`
    FROM
      system.billing.usage
    WHERE
      usage_metadata.dlt_pipeline_id = :dlt_pipeline_id
      AND usage_start_time >= :usage_start_time
      AND usage_end_time < :usage_end_time
    GROUP BY
      ALL

    The identity_metadata struct records who the usage ran as. What run_as means depends on the workload. For jobs it is the job's configured run-as principal, which defaults to the owner. For Lakeflow pipelines it is the principal whose permissions run the pipeline. For all-purpose compute it is the identity that created the cluster, which isn't necessarily the current owner.

    Checkpoint 2 of 9· Match them up

    A FinOps analyst wants to tag each workload's spend in system.billing.usage. Match each workload to the usage_metadata key that identifies it on its billing rows.

    Tap a term, then the definition that fits it.

    Sources345

    3.Turning DBUs into money with system.billing.list_prices

    Usage rows count DBUs, not currency. The price is in system.billing.list_prices, a historical log with one row per price period for each sku_name, cloud and usage_unit. Each row has price_start_time, price_end_time, a currency_code such as USD, and a pricing struct. In that struct, pricing.default always returns a single list price that you can use for simple long-term estimates.

    To get cost, join each usage row to the price row with the same sku_name, cloud and usage_unit whose window contains the usage. The usage start time should be on or after price_start_time and before price_end_time, or price_end_time should be null if that price is still current. Then multiply usage_quantity by pricing.default. Matching on the time window matters because a price change adds a new row rather than overwriting the old one. Last year's usage should be priced at last year's rate.

    Checkpoint 3 of 9· Check yourself

    To price last year's DBUs, an analyst joins system.billing.usage to system.billing.list_prices on sku_name, cloud and usage_unit. The analyst keeps only price rows where price_end_time IS NULL and multiplies usage_quantity by pricing.default. What is wrong with the resulting cost?

    Sources4

    4.Attributing classic compute spend with system.compute.clusters

    system.compute.clusters is a slowly changing dimension. Databricks adds a new row each time a cluster's configuration changes, so the table holds the full configuration history of all-purpose, job and pipeline compute. Each row has the cluster_name, the owned_by user, the driver_node_type and worker_node_type, and either a fixed worker_count or min_autoscale_workers/max_autoscale_workers. It also records auto_termination_minutes, the dbr_version and cluster_source. cluster_source is UI or API for all-purpose compute, JOB for all job compute, and PIPELINE or PIPELINE_MAINTENANCE for pipelines.

    On all-purpose compute, identity_metadata.run_as only tells you who created the cluster. To charge spend to the current owner, join usage to clusters on usage_metadata.cluster_id and take owned_by from the configuration version that was in effect when the usage happened:

    Usage per cluster, attributed to the owner in effect at the time of usesql
    SELECT
      u.record_id record_id,
      c.cluster_id cluster_id,
      max_by(c.owned_by, c.change_time) owned_by,
      max(c.change_time) change_time,
      any_value(u.usage_start_time) usage_start_time,
      any_value(u.usage_quantity) usage_quantity
    FROM
      system.billing.usage u
      JOIN system.compute.clusters c
    WHERE
      u.usage_metadata.cluster_id is not null
      and u.usage_start_time >= '2025-01-01'
      and u.usage_metadata.cluster_id = c.cluster_id
      and c.change_time <= u.usage_start_time
    GROUP BY 1, 2
    ORDER BY cluster_id, usage_start_time desc;

    This join is also where a cost spike turns into a fix. Suppose an all-purpose cluster with auto_termination_minutes set to 0 runs all week, and its owned_by is a service principal that no team claims. The DBUs come from idle time and nobody is responsible for them. The fix is in the cluster's own configuration. Set an auto-termination window so idle time stops costing DBUs, and change the owner through the Clusters API so future usage is charged to the team that runs it. Raising min_autoscale_workers would do the opposite, because it raises the floor of workers the cluster keeps. Each configuration change you make appears as a new row in clusters.

    Node roles only need care when the driver and workers use different instance types. In that case usage comes as two records, one per instance type. If both use the same type, the usage is combined into a single record. To split usage by node role, cross-reference driver_node_type/worker_node_type in clusters, or the driver boolean in system.compute.node_timeline. node_timeline holds per-minute utilisation for each node.

    Checkpoint 4 of 9· Check yourself

    Alice created an all-purpose cluster. Last month, ownership was moved to the data team's service principal through the Clusters API. A chargeback report groups this month's all-purpose spend in system.billing.usage by identity_metadata.run_as. Who does the report charge for this cluster's usage?

    Checkpoint 5 of 9· Exam question

    Monthly compute spend has spiked. An engineer joins system.compute.clusters to system.billing.usage and finds several all-purpose clusters with autotermination_minutes = 0 running continuously under a shared owned_by service principal that no longer maps to an active team. What is the most effective first remediation based on this system table data?

    Sources675

    5.Job and pipeline cost with the system.lakeflow tables

    The system.lakeflow schema records job and pipeline activity. It used to be called workflow, and both names hold identical content. It contains two kinds of table, and you query them differently. jobs, job_tasks and pipelines are SCD2 dimensions: any change adds a new row, and a deletion adds a row with delete_time set rather than removing anything. job_run_timeline, job_task_run_timeline and pipeline_update_timeline are immutable facts that record when each run, task run or update started and ended. They never need deduplication.

    Current state of every job: newest row per entity first, deleted jobs excluded afterwardssql
    -- Get the current state of every job, excluding deleted jobs
    with latest AS (
      SELECT
        *,
        ROW_NUMBER() OVER(PARTITION BY workspace_id, job_id ORDER BY change_time DESC) as rn
      FROM
        system.lakeflow.jobs QUALIFY rn=1
    )
    SELECT * FROM latest WHERE delete_time IS NULL

    The filter order is easy to get wrong. If you filter delete_time IS NULL while reading the table, a deleted job's earlier rows still match the filter. The query then returns the job's last state before deletion instead of leaving the job out. The partition key changes with the table: workspace_id, job_id for jobs, workspace_id, job_id, task_key for job_tasks, and workspace_id, pipeline_id for pipelines.

    workspace_id appears in every one of those keys because a job_id is only unique within a single workspace. Two workspaces can both have a job 42. This is why cost-to-run attribution needs three equalities, not one. A usage row belongs to a run in job_run_timeline when u.workspace_id = rt.workspace_id, u.usage_metadata.job_id = rt.job_id and u.usage_metadata.job_run_id = rt.run_id. Shortcut joins fail. A cluster ID matched against a job ID compares different kinds of value. A SKU name says what kind of compute was billed, not which job used it. A run_as principal can run many jobs.

    Runs longer than an hour are split across several hourly rows in the timeline tables, using period_start_time and period_end_time. result_state is filled only on the row that covers the end of the run. To count failures, take each run's final row instead of every slice. Pipelines follow the same pattern: usage_metadata.dlt_pipeline_id and dlt_update_id link billing to pipelines and pipeline_update_timeline. Event-level detail about a pipeline's flows and expectations comes from its pipeline event log.

    Checkpoint 6 of 9· Fill the gap

    This query should return the current state of every job and leave out jobs that have been deleted. Which source belongs in the blank so that deleted jobs are actually left out?

    -- Get the current state of every job, excluding deleted jobs
    with latest AS (
      SELECT
        *,
        ROW_NUMBER() OVER(PARTITION BY workspace_id, job_id ORDER BY change_time DESC) as rn
      FROM
        system.lakeflow.jobs QUALIFY rn=1
    )
    SELECT * FROM  ?  WHERE delete_time IS NULL

    Checkpoint 7 of 9· Exam question

    A FinOps engineer must attribute each dollar of Databricks Jobs compute to the specific job run that generated it, joining system.billing.usage with system.lakeflow.job_run_timeline. The engineer starts from this skeleton: SELECT u.usage_quantity, u.sku_name, rt.job_id, rt.run_id FROM system.billing.usage u JOIN system.lakeflow.job_run_timeline rt ON <JOIN_CONDITION> Which <JOIN_CONDITION> correctly attributes each usage record to the job run that produced it?

    Sources2

    6.Auditing activity with system.access.audit

    system.access.audit has one row per logged event. Six columns do most of the work in an investigation. service_name names the service that emitted the event, such as unityCatalog. action_name names the operation, such as getTable. user_identity holds the caller's email or principal name. request_params is a map of the request's arguments, such as full_name_arg for the object touched. response is a struct with the status code and any error. event_time/event_date say when it happened. audit_level separates workspace-level from account-level events, and account-level events record workspace_id as 0.

    Suppose a service principal is suspected of exporting data out of hours. A useful query narrows on what happened, who did it and when, and keeps all three filters. Filter action_name to the operation under investigation and user_identity to that principal. Use event_date to bound the date range, because it is the column that speeds queries up, and use the hour of event_time to keep only events outside working hours. A single filter on its own doesn't answer the question.

    Why single-column audit filters mislead
    Filter aloneWhat it actually returns
    A success status in the response structEvery successful event of any kind. Success describes the outcome, not the type of action
    service_name of the compute serviceCluster lifecycle events, not the data operation itself
    request_params full_name_arg onlyEvery access to that object by every identity, at any hour
    audit_level = ACCOUNT_LEVELOnly account-level events (workspace_id 0), dropping workspace-level ones without saying anything about the actor

    Two details affect what you can read. identity_metadata.run_by is the identity that started the event, and run_as is the identity whose permissions authorised it. When an OAuth app acts on a user's behalf, the acting_resource fields name the app. Some keys in request_params that hold SQL definitions are hidden unless you are an account admin or in the databricks_pii_access group. These are view_definition, function_info, definition_json and managed_definition. All other columns are returned unchanged.

    Checkpoint 8 of 9· Match them up

    During an incident review, a security engineer queries system.access.audit to find out who did what, on whose authority, and when. Match each audit column or value to what it tells the engineer.

    Tap a term, then the definition that fits it.

    Checkpoint 9 of 9· Exam question

    A security team suspects that a service principal exported large tables outside normal business hours. They plan to investigate using system.access.audit, which records event_time, service_name, action_name, user_identity, request_params, response, and audit_level for every logged event. Which two filters should they combine to surface the suspicious export events? (Choose two)(Select 2)

    0 of 2 selected

    Sources8

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “System tables are free to use. You are only charged for the compute used to query them.”
      ↩︎ What system tables are and who can query them
      “USE CATALOG on the system catalog, USE SCHEMA on the system schemas, and SELECT on the system schemas”
      ↩︎ What system tables are and who can query them
      “System tables are read-only and cannot be modified.”
      ↩︎ What system tables are and who can query them
      “they include operational data from non-Unity Catalog workspaces in your account.”
      ↩︎ What system tables are and who can query them
      “System tables provide a Databricks-hosted analytical store of your account's operational data.”
      ↩︎ Key concept
      “A historical log of SKU pricing. A record gets added each time there is a change to a SKU price.”
      ↩︎ Checkpoint
    2. 2.
      “To see records from another region, you must view the tables from a workspace deployed in that region.”
      ↩︎ What system tables are and who can query them
      “The lakeflow schema was previously known as workflow.”
      ↩︎ Job and pipeline cost with the system.lakeflow tables
      “The job run timeline, job task run timeline, and pipeline update timeline tables are immutable, so they need no deduplication.”
      ↩︎ Job and pipeline cost with the system.lakeflow tables
      “Deletions are recorded as a new row with delete_time populated, not by removing rows.”
      ↩︎ Job and pipeline cost with the system.lakeflow tables
      “This key is only unique within a single workspace”
      ↩︎ Job and pipeline cost with the system.lakeflow tables
      “For runs longer than one hour that are split across multiple rows”
      ↩︎ Job and pipeline cost with the system.lakeflow tables
      “Only unique within a single workspace”
      ↩︎ Exam trap 2
      “Apply the delete_time filter after selecting the most recent row”
      ↩︎ Exam trap 3
    3. 3.
      “Databricks consumption in Databricks units (DBUs)”
      ↩︎ Reading system.billing.usage
    4. 4.
      “The unit of measurement that is monetized.”
      ↩︎ Reading system.billing.usage
      “A record gets added each time there is a change to a SKU price.”
      ↩︎ Turning DBUs into money with system.billing.list_prices
      “The key default will always return a single price that can be used for simple long-term estimates.”
      ↩︎ Turning DBUs into money with system.billing.list_prices
    5. 5.
      “Records are typically available within 12 hours.”
      ↩︎ Reading system.billing.usage
      “The value is ORIGINAL unless the record is related to a correction.”
      ↩︎ Reading system.billing.usage
      “Only a subset of these values is populated in any given usage record, depending on the compute type and features used.”
      ↩︎ Reading system.billing.usage
      “The identity that created the compute resource. This is not necessarily the compute owner.”
      ↩︎ Reading system.billing.usage
      “When the compute's driver and worker nodes use different instance types, their usage appears as separate records”
      ↩︎ Attributing classic compute spend with system.compute.clusters
      “Serverless jobs and jobs run on job compute (does not populate for jobs run on all-purpose compute)”
      ↩︎ Exam trap 1
      “To attribute usage to the owner, join to system.compute.clusters.owned_by using usage_metadata.cluster_id.”
      ↩︎ Exam trap 4
      “Serverless jobs and jobs run on job compute (does not populate for jobs run on all-purpose compute)”
      ↩︎ Prediction
      “This is not necessarily the compute owner. To attribute usage to the owner, join to system.compute.clusters.owned_by using usage_metadata.cluster_id.”
      ↩︎ Checkpoint
    6. 6.
      “Defaults to the cluster creator, but can be changed through the Clusters API.”
      ↩︎ Attributing classic compute spend with system.compute.clusters
      “All job compute is logged as JOB. Pipelines are PIPELINE or PIPELINE_MAINTENANCE.”
      ↩︎ Attributing classic compute spend with system.compute.clusters
    7. 7.
      “join the usage table with the compute.clusters table to find out which compute resource owners”
      ↩︎ Attributing classic compute spend with system.compute.clusters
    8. 8.
      “To improve query performance, filter on event_date rather than event_time.”
      ↩︎ Auditing activity with system.access.audit
      “Account-level audit logs record workspace_id as 0.”
      ↩︎ Auditing activity with system.access.audit
      “run_by is the identity that initiated the event, and run_as is the identity used for authorization.”
      ↩︎ Auditing activity with system.access.audit
      “Those keys are omitted unless you are an account admin or a member of the databricks_pii_access account-level group”
      ↩︎ Auditing activity with system.access.audit

    Spotted a mistake, or was something unclear? Tell us.