<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Queries for Cost Attribution using System Tables in Technical Blog</title>
    <link>https://community.databricks.com/t5/technical-blog/queries-for-cost-attribution-using-system-tables/ba-p/76558</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Organizations have expressed the need to see trends across their Databricks Accounts and drill down into Workspaces, SKUs, tags, and users. &lt;A href="https://docs.databricks.com/en/admin/system-tables/index.html" target="_self"&gt;System Tables&lt;/A&gt; provide this visibility with little to no setup needed, just an API call to opt into certain schemas. In this blog, we will leverage Databricks System Tables for cost observability by using the billing, access, query, and compute schemas. We include a common template for a Lakeview Dashboard that is versioned and shareable in a &lt;A href="https://github.com/databricks-solutions/databricks-blogposts" target="_self"&gt;public repo&lt;/A&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Sourcing common insights from System Tables&amp;nbsp;&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P data-unlink="true"&gt;&lt;SPAN&gt;System tables provide a centralized way to gain insights into how your Databricks resources are functioning and changing over time. They must be &lt;A href="https://docs.databricks.com/en/administration-guide/system-tables/index.html" target="_self"&gt;enabled&lt;/A&gt; by an account admin and operate at the schema level.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Core System Tables needed to source cost attribution&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;Here are the tables that will help you gain insights into the Account's cost analysis and drill down into the Workspaces, Warehouses, Clusters, Users, and Tags.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;Table name&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;Definition&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Contains entries for events broken out by Service and Action Names. For example, we filter on the notebook service and runCommand to determine the duration of a command run.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Helps us correlate runs from query history and the access audit tables to what was billed and by whom.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Captures user-level query execution information.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.compute.clusters&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Contains events relating back to the cluster configuration.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.list_prices&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Contains the list prices for a period.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Building insights into cost attribution&amp;nbsp;&lt;/SPAN&gt;&lt;/H2&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by tags&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;The billing table provides a &lt;EM&gt;custom_tags&lt;/EM&gt; field that can be used as a parameter to filter workloads that are appropriately tagged.&amp;nbsp; The Tags column in the billing usage table is a map that can be filtered with &lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dashboards/parameters" target="_self"&gt;Lakeview Parameters&lt;/A&gt; by leveraging a simple condition to select all tags or specific ones filtering on the key and value of the map as seen below.&amp;nbsp; These Parameters can then be part of the dashboard to filter the visuals appropriately:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;       :tag_name :: string = 'all'

       or u.custom_tags [:tag_name::string] = :tag_value :: string&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Parameters for Tag Name and Tag Value in the Dashboard&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;column&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;data type&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;source&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;description&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;workspace_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The unique ID of the workspace&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;workspace_name&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The name of the workspace&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;usage_date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Activity date on the workspace&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;cost&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.list_prices&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Total cost on the workspace per day&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Tag&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Tag name&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Value&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Value of tag&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by account&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;The combo chart below displays month-over-month analysis for dollars and DBUs consumed for the Databricks account, representing the consumption of all Workspaces provisioned with the cloud provider used.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Account Trends dbus &amp;amp; $dbus.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9218iEE48CDC16331912B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Account Trends dbus &amp;amp; $dbus.png" alt="Account Trends dbus &amp;amp; $dbus.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by Workspace&amp;nbsp;&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;The below bar chart shows a drill down into Workspace consumption month over month.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorsamerzabaneh_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Workspace ID Trends by Month copy.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9220i3C9C40432F191CCD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Workspace ID Trends by Month copy.png" alt="Workspace ID Trends by Month copy.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by SKU&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;The bar chart below shows the month-over-month $DBU consumption for various Databricks SKUs. The SKUs are taken from the &lt;EM&gt;sku_name&lt;/EM&gt; field in the Usage table, and a simple case statement below gives us the categories of interest. Of course, these can be rolled up to a higher level with the new fields provided in the Usage table, &lt;EM&gt;product_features&lt;/EM&gt; and &lt;EM&gt;billing_origin_product&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sku Trends by Month.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9221i68B84C3F4F68CD28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Sku Trends by Month.png" alt="Sku Trends by Month.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use this case-when statement to help summarize consumption by product SKU.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;   Case
     when u.sku_name like '%SERVERLESS_SQL%' then 'SQL-Serverless'
     when u.sku_name like '%SQL_PRO%' then 'SQL-Pro'
     when u.sku_name like '%SQL%' then 'SQL-Classic'
     WHEN u.sku_name like '%DLT_ADVANCED_COMPUTE%'
     and u.sku_name like '%PHOTON%' THEN 'DLT Advanced (PHOTON)'
     WHEN u.sku_name like '%DLT_ADVANCED_COMPUTE%' THEN 'DLT Advanced'
     WHEN u.sku_name like '%DLT_PRO_COMPUTE%'
     and u.sku_name like '%PHOTON%' THEN 'DLT Pro (PHOTON)'
     WHEN u.sku_name like '%DLT_PRO_COMPUTE%' THEN 'DLT Pro'
     WHEN u.sku_name like '%DLT_CORE_COMPUTE%'
     and u.sku_name like '%PHOTON%' THEN 'DLT Core (PHOTON)'
     WHEN u.sku_name like '%DLT_CORE_COMPUTE%' THEN 'DLT Core'
     when u.sku_name like '%JOBS%'
     and u.sku_name like '%PHOTON%' then 'AUTOMATED (PHOTON)'
     when u.sku_name like '%JOBS%' then 'AUTOMATED'
     when u.sku_name like '%ALL_PURPOSE%'
     and u.sku_name like '%PHOTON%' then 'INTERACTIVE (PHOTON)'
     when u.sku_name like '%ALL_PURPOSE%' then 'INTERACTIVE'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by Warehouse&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;This widget in the cost attribution dashboard represents the weekly cost for a DBSQL Warehouse.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Warehouse Cost over Period copy.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9222iF5FFE3199A404887/image-size/large?v=v2&amp;amp;px=999" role="button" title="Warehouse Cost over Period copy.png" alt="Warehouse Cost over Period copy.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;SPAN&gt;Warehouse insights by user&lt;/SPAN&gt;&lt;/H4&gt;
&lt;P&gt;&lt;SPAN&gt;The below table shows the hourly warehouse consumption pattern and ties back the warehouse usage cost to a user.&amp;nbsp; How it ties back to the usage is based on grouping the query history table into hours in the day so that the duration of the queries executed within the hour ties back to the Usage table for cost.&amp;nbsp; A simple calculation of the duration of the query compared to the hourly total cost can give a sense of the percentage of cost that can be attributed to a user.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;*As a disclaimer, the estimates below depict the duration of the query relative to the Usage tables billing for that hour. Other factors may be needed for appropriate chargeback, but this gives a reasonable view of what users are contributing to costs based on query time.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This below table shows the hourly warehouse consumption pattern and ties back the cluster usage cost to a user.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cost_per_user_warehouse.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9230i0B963768F0B0D08C/image-size/large?v=v2&amp;amp;px=999" role="button" title="cost_per_user_warehouse.png" alt="cost_per_user_warehouse.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Warehouse top users per duration (1).png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9238iB67C7C8A0035237A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Warehouse top users per duration (1).png" alt="Warehouse top users per duration (1).png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below is a snippet of how this is achieved, while the full code can be found in the &lt;A href="https://github.com/databricks-solutions/databricks-blogposts" target="_self"&gt;repo&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;with usage_by_user as (
  select
    workspace_id,
    executed_by,
    compute.warehouse_id,
    date(start_time) `event_date`,
    hour(start_time) `hour`,
    sum(total_duration_ms) / 1000 `total_duration_by_user_in_hour`,
    (
      select
        sum(qhs.total_duration_ms) / 1000
      from
        system.query.history qhs
      where
        date(qhs.start_time) = date(qh.start_time)
        and date(qhs.end_time) = date(qh.end_time)
        and hour(qhs.start_time) = hour(qh.start_time)
        and qhs.workspace_id = qh.workspace_id
        and qhs.workspace_id = :workspace_id::string
        and qhs.compute.warehouse_id = qh.compute.warehouse_id
      group by
        date(qhs.start_time),
        hour(qhs.start_time),
        qhs.workspace_id,
        qhs.compute.warehouse_id
    ) `total_duration_by_hour`
  from
    system.query.history qh
  where
    date(start_time) &amp;gt;= date_add(week, - :duration_in_weeks :: integer, now())
    and qh.workspace_id = :workspace_id::string
  group by
    all
)
select
  u.workspace_id,
  u.executed_by,
  u.warehouse_id,
  u.event_date,
  u.hour,
  round(t.dollar_dbus, 2) `cost_by_hour`,
  round(t.DBUs, 2) `dbus_by_hour`,
  u.total_duration_by_user_in_hour,
  u.total_duration_by_hour,
  t.custom_tags,
  round(
    (
      total_duration_by_user_in_hour / total_duration_by_hour
    ) * 100,
    2
  ) `percent_consumption_by_user_in_hour`,
  round(
    t.dollar_dbus * `percent_consumption_by_user_in_hour` / 100,
    2
  ) `cost_by_user_in_hour`
from
  usage_by_user u
  inner join (
    select
      date(u.usage_start_time) `event_date`,
      hour(u.usage_start_time) `hour`,
      u.workspace_id,
      u.usage_metadata.warehouse_id `warehouse_id`,
      to_json(u.custom_tags) `custom_tags`,
      round(sum(usage_quantity), 2) `DBUs`,
      sum(usage_quantity * lp.pricing.default) `dollar_dbus`
    from
      system.billing.usage u
      INNER JOIN system.billing.list_prices lp ON u.account_id = lp.account_id
      and u.cloud = lp.cloud
      and u.sku_name = lp.sku_name
      and u.workspace_id = :workspace_id::string
      and u.usage_start_time between lp.price_start_time
      and coalesce(lp.price_end_time, u.usage_end_time)
      and u.usage_date &amp;gt;= date_add(week, - :duration_in_weeks :: integer, now())
      and u.sku_name like '%SQL%'
      and (
        :tag_name :: string = 'all'
        or u.custom_tags [:tag_name::string] = :tag_value :: string
      )
    group by
      all
  ) T ON u.workspace_id = T.workspace_id
  and u.workspace_id = :workspace_id::string
  and u.warehouse_id = t.warehouse_id
  and u.event_date = t.event_date
  and u.hour = t.hour 
order by
  event_date asc,
  hour asc&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;SPAN&gt;&lt;BR /&gt;Warehouse insights metrics&lt;/SPAN&gt;&lt;/H4&gt;
&lt;TABLE class=" lia-align-center" style="height: 943px; border-style: solid;"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;column&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;data type&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;source&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;description&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;workspace_id&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the workspace this query statement belongs to&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;warehouse_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history.compute&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the warehouse this query statement runs on&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;total_cost_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Usage by SKU(e.g Compute Type)&amp;nbsp; per Hour in dollars&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;total_dbus_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Usage by SKU(e.g Compute Type)&amp;nbsp; per Hour in dbus&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;total_consumption_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;diff(request.starttime - request_params.endttime)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="50px"&gt;
&lt;P&gt;&lt;SPAN&gt;total_consumption_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="50px"&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="50px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="50px"&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total usage per hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;percent_of_consumption_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;derived field&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total usage percentage per hour in the warehouse&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;cost_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;derived field&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total cost per hour in the warehouse&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;tags&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;MAP&amp;lt;STRING, STRING&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;The user-supplied tags associated with this warehouse&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;executed_by&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the principal who ran the query&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;event_date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;The day when the query was executed&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.125px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;event_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="129.913px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="158.15px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;system.query.history&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="233.8px" height="77px"&gt;
&lt;P&gt;&lt;SPAN&gt;The time when the query was executed&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Cost attribution by cluster&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;The bar chart below looks at cluster costs over a time period. The query uses the audit, usage, and cluster tables to display trends. When working with the clusters table, it is important to ensure the max record is taken to retrieve the latest configuration, as seen in the code snippet below. A subquery is leveraged to retrieve the max change record for a given cluster and join against the usage table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cluster Cost over Period (2).png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9239iD10060A7CBA93FD0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cluster Cost over Period (2).png" alt="Cluster Cost over Period (2).png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt; inner join (
   select
     max(change_time),
     cluster_name,
     cluster_id,
     workspace_id,
     account_id
   from
     system.compute.clusters
   group by
     all
 )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;SPAN&gt;Cluster insights by user&lt;/SPAN&gt;&lt;/H4&gt;
&lt;P&gt;&lt;SPAN&gt;The below table shows the hourly cluster consumption and ties back the usage to a user.&amp;nbsp; How it ties back to the usage is based on grouping the audit log tables and duration of runCommand queries into hours in the day so that the duration of the queries executed within the hour ties back to the Usage table for cost.&amp;nbsp; A simple calculation of the duration of the query compared to the hourly total cost can give a sense of the percentage of cost that can be attributed to the user.&amp;nbsp; It is important to note that considering this is using the Audit Log table, the insights gathered are dependent on &lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/admin/account-settings/audit-logs#:~:text=notebook-,runCommand,-Available%20when%20verbose" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;verbose logs&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; being enabled to capture notebook commands being run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;*As a disclaimer, the estimates below depict the duration of the query relative to the Usage tables billing for that hour. Other factors may be needed for appropriate chargeback, but this gives a reasonable view of what users are contributing to costs based on query time.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The below table shows the hourly cluster consumption pattern and ties back the cluster usage cost to a user.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cost_per_user_cluster.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9228i77E7F209A36B31A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="cost_per_user_cluster.png" alt="cost_per_user_cluster.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cluster top users per duration (1).png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/9240i603C3B06EB361A6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cluster top users per duration (1).png" alt="Cluster top users per duration (1).png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below is a snippet of how this is achieved while the full code can be found in the &lt;A href="https://github.com/databricks-solutions/databricks-blogposts" target="_self"&gt;repo&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;with usage_by_user as (
 select
   a.workspace_id,
   a.user_identity.email,
   a.request_params.clusterId `cluster_id`,
   a.event_date,
   hour(a.event_time) `hour`,
   sum(a.request_params.executionTime) `total_duration_by_user_in_hour`
 from
   system.access.audit a
 where
   a.service_name in ('notebook', 'jobs')
   and a.action_name = 'runCommand'
   and a.event_date &amp;gt;= date_add(week, - :duration_in_weeks :: integer, now())
   and a.request_params.clusterId is not null --and a.workspace_id = :workspace_id :: string
 group by
   all
),
total_cost_by_cluster as (
 select
   a1.event_date `event_date`,
   hour(a1.event_time) `hour`,
   a1.request_params.clusterId `clusterId`,
   sum(a1.request_params.executionTime) `total_duration_by_hour`
 from
   system.access.audit a1
 where
   a1.service_name in ('notebook', 'jobs')
   and a1.action_name = 'runCommand'
   and a1.event_date &amp;gt;= date_add(week, - :duration_in_weeks :: integer, now())
   and a1.request_params.clusterId is not null --and a1.workspace_id = :workspace_id :: string
 group by
   all
)
select
 u.workspace_id,
 u.email `executed_by`,
 c.cluster_name,
 u.cluster_id,
 u.event_date,
 u.hour,
 round(t.dollar_dbus, 2) `cost_by_hour`,
 t.DBUs `dbus_by_hour`,
 u.total_duration_by_user_in_hour,
 tc.total_duration_by_hour,
 t.custom_tags,
 round(
   (
     total_duration_by_user_in_hour / total_duration_by_hour
   ) * 100,
   2
 ) `percent_consumption_by_user_in_hour`,
 round(
   t.dollar_dbus * `percent_consumption_by_user_in_hour` / 100,
   2
 ) `cost_by_user_in_hour`
from
 usage_by_user u
 inner join total_cost_by_cluster tc on u.event_date = tc.event_date
 and u.hour = tc.hour
 and u.cluster_id = tc.clusterId
 inner join (
   select
     date(u.usage_start_time) `event_date`,
     hour(u.usage_start_time) `hour`,
     u.workspace_id,
     u.usage_metadata.cluster_id `cluster_id`,
     to_json(u.custom_tags) `custom_tags`,
     round(sum(usage_quantity), 2) `DBUs`,
     sum(usage_quantity * lp.pricing.default) `dollar_dbus`
   from
     system.billing.usage u
     INNER JOIN system.billing.list_prices lp ON u.account_id = lp.account_id
     and u.cloud = lp.cloud
     and u.sku_name = lp.sku_name
     and u.usage_start_time between lp.price_start_time
     and coalesce(lp.price_end_time, u.usage_end_time)
     and u.usage_date &amp;gt;= date_add(week, - :duration_in_weeks :: integer, now())
     and u.sku_name like '%ALL_PURPOSE%'
     and (
       :tag_name :: string = 'all'
       or u.custom_tags [:tag_name::string] = :tag_value :: string
     )
   group by
     all
 ) T ON u.workspace_id = T.workspace_id
 and u.cluster_id = t.cluster_id
 and u.event_date = t.event_date
 and u.hour = t.hour
 inner join (
   select
     max(change_time),
     cluster_name,
     cluster_id,
     workspace_id,
     account_id
   from
     system.compute.clusters
   group by
     all
 ) c on c.cluster_id = u.cluster_id
 and c.workspace_id = u.workspace_id
order by
 event_date asc,
 hour asc

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;SPAN&gt;&lt;BR /&gt;Cluster insights metrics&lt;/SPAN&gt;&lt;/H4&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;column&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;data type&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;source&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;description&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;workspace_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the workspace this command statement belongs to&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;cluster_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the cluster this command statement belongs to&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;cluster_name&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The name of the cluster this command statement belongs to&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;total_cost_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Usage by SKU(e.g Compute Type)&amp;nbsp; per Hour in dollars&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;total_dbus_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Usage by SKU(e.g Compute Type)&amp;nbsp; per Hour in dbus&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;total_consumption_by_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;diff(request.starttime - request_params.endttime)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;total_consumption_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total usage per hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;percent_of_consumption_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;derived field&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total usage percentage per hour in the cluster&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;cost_by_user_in_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Decimal&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;derived field&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;User’s total cost per hour in the cluster&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;tags&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;MAP&amp;lt;STRING, STRING&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The user-supplied tags associated with this warehouse&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;executed_by&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;String&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The ID of the principal who ran the commands&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;event_date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The day when the command was executed&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;event_hour&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;system.access.audit&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;The time when the command was executed&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;H1&gt;&lt;SPAN&gt;&lt;BR /&gt;Conclusion&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;In this blog post, we covered key tables needed to gather insights for cost attribution. The samples provided detailed cost analyses for DBSQL Warehouses, clusters, Workspaces, SKUs, and ysers. This allows organizations to see growing trends in their consumption, which will empower them to make informed decisions, optimize resource utilization, and effectively manage their Databricks consumption across different teams, workspaces, and use cases.&amp;nbsp; Sharing this template with Lakeview Dashboards is the beginning of more templates to come as System Tables evolve.&amp;nbsp; This template can be imported easily by downloading it from the public repo and &lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dashboards/#:~:text=Export%2C%20import%2C%20or%20replace%20a%20dashboard" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;importing&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; it into a Databricks Workspace with Unity Catalog enabled.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 13:45:47 GMT</pubDate>
    <dc:creator>samer_zabaneh</dc:creator>
    <dc:date>2024-07-10T13:45:47Z</dc:date>
    <item>
      <title>Queries for Cost Attribution using System Tables</title>
      <link>https://community.databricks.com/t5/technical-blog/queries-for-cost-attribution-using-system-tables/ba-p/76558</link>
      <description>&lt;P&gt;Many customers want visibility into how users contribute to cost. At the moment, users are not tracking cost, but there is a loose association that can be made with the Query History for Warehouses and Cluster records in the Audit Logs for Notebooks and Jobs.&amp;nbsp; For Notebooks and Jobs, we are leveraging runCommand which requires verbose auditing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 13:45:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/queries-for-cost-attribution-using-system-tables/ba-p/76558</guid>
      <dc:creator>samer_zabaneh</dc:creator>
      <dc:date>2024-07-10T13:45:47Z</dc:date>
    </item>
  </channel>
</rss>

