Slide 1

Slide 1 text

©2024 Databricks Inc. — All rights reserved Databricks Japan モニタリング: システムテーブルを用いて使用状況を 監視する

Slide 2

Slide 2 text

©2024 Databricks Inc. — All rights reserved システムテーブルとは 2 Databricksはユーザーのログイン状況、クラスターの稼働状況、コストなどをストア しており、コスト管理や不審なアクティビティの監視に活用できます 監査ログ 使用量 クラスター 価格 データソース システムテーブル UX Export Data Admin Billing Admin Data Engineering Data Analyst Data Scientist ‥

Slide 3

Slide 3 text

©2024 Databricks Inc. — All rights reserved システムテーブルはアカウントに紐づけられており、UC有効化されているワークス ペースから有効化&全てのワークスペースの情報を取得できます システムテーブルの有効化 監査ログ 使用量 クラスター 価格 組織 アカウント システムテーブル ワークスペース1 ‥ ワークスペース2 ワークスペース3 ‥ UC有効化されている 全ワークスペース取得 ワークスペース1がUC有効化さ れている場合、 ワークスペース1から全てのワー クスペースの情報を取得可能

Slide 4

Slide 4 text

©2024 Databricks Inc. — All rights reserved システムテーブルでできること Databricks使用料を監視 & 請求額が基準を超えた場合のアラート機能をはじめと した、様々な機能を提供しています

Slide 5

Slide 5 text

©2024 Databricks Inc. — All rights reserved システムテーブルでできること ダッシュボードのスケジュール機能を使って、アカウントに関する様々な操作・指標を 監視できます

Slide 6

Slide 6 text

©2024 Databricks Inc. — All rights reserved Demo: Jobクラスターコスト分析 ユーザー、ジョブ、タグ別にどの程度Databricksを使用しているかを把握することで ベースラインを特定し、異常値を検知します ● ジョブ・ユーザー別使 用状況 ● トレンド・サマリー ● WoW/MoMの変化 ● 分布 ● 異常値

Slide 7

Slide 7 text

©2024 Databricks Inc. — All rights reserved 予算や、チーム・ユーザーの使用量が一定額を超えたときにアラートを通知します 通知先 ● Slack ● Teams ● PagerDuty ● メール ● Webhook Demo: 予算アラート

Slide 8

Slide 8 text

©2024 Databricks Inc. — All rights reserved システムテーブルで扱えるデータ 8 テーブル 説明 場所 監査ログ アカウント全体のすべての監査イベントのレコードが含まれています。 system.access.audit 課金対象使用状況 アカウント全体が課金対象のすべての使用状況のレコードが含まれています。各使用状況レ コードは、リソースの課金対象の使用量を 1 時間ごとに集計したものです。 system.billing.usage 料金 SKU 価格の履歴ログです。SKU 価格が変更されるたびに追加されます。 system.billing.list_prices クラスター 任意のクラスターの時間の経過に伴うクラスター構成の全履歴を含む、ディメンジョン テーブルで す。 system.compute.clusters SQLウェアハウス SQL ウェアハウスに関連するイベントをキャプチャします。 たとえば、開始、停止、実行、スケー ルアップ、スケールダウンです。 system.compute.wareho use_events 監査ログ以外にも課金状況、クラスターの起動時間といったデータを取得できます (参考)システム テーブルを使用して使用状況を監視する

Slide 9

Slide 9 text

©2024 Databricks Inc. — All rights reserved

Slide 10

Slide 10 text

©2024 Databricks Inc. — All rights reserved Appendix① 各システムテーブルの用途

Slide 11

Slide 11 text

©2024 Databricks Inc. — All rights reserved ● 誰がこのテーブルにアクセスしたのか? ● 直近1日以内にどのユーザーがテーブルにアクセスした か? ● ユーザーがどのテーブルにアクセスしたか? ● すべてのパーミッションの変更を表示 ● 最近実行したノートブックコマンドを表示 Audit Log 監査ログは、アカウント使用に関する一般的な質問に答えるのに役立ちます

Slide 12

Slide 12 text

©2024 Databricks Inc. — All rights reserved ● DBU消費量の日次推移は? ● 今月、各SKUは何DBU使用されたか? ● あるワークスペースが6月1日に使用した各SKUの量は? ● 最もDBUを消費したジョブは? ● 特定のタグを持つリソースにどれだけの使用量を帰属さ せることができるか? ● 利用が伸びているSKUを示す ● All Purpose Compute (Photon)の使用傾向は? Billing usage usageテーブルを活用したDBU消費の分析と最適化

Slide 13

Slide 13 text

©2024 Databricks Inc. — All rights reserved リネージュテーブルは2つある: ● system.access.table_lineage ● system.access.column_lineage Table and Column Lineage Unity Catalogのリネージュ機能を利用して、リネージュをプログラムで照会し、意思決 定やレポートの作成に役立てることができます

Slide 14

Slide 14 text

©2024 Databricks Inc. — All rights reserved Clusters インフラの使用状況とスケーリングイベントを理解する • クラスターはどのくらい稼働していたのですか? • どのようなVMタイプを使用したのですか? • どのように規模を拡大/縮小したのか スキーマ ● system.compute.clusters ● system.compute.node_timeline ● system.compute.node_types ● system.compute.warehouse_events

Slide 15

Slide 15 text

©2024 Databricks Inc. — All rights reserved Query データが誰にどのように照会されているかを理解する • 最も使用頻度の高いテーブル/カラム は? • テーブルはどのようにクエリされるのか? • 誰がどのデータを見るのか?

Slide 16

Slide 16 text

©2024 Databricks Inc. — All rights reserved Appendix② Query Sample

Slide 17

Slide 17 text

©2024 Databricks Inc. — All rights reserved SELECT action_name as `EVENT`, event_time as `WHEN`, IFNULL(request_params.full_name_arg, 'Non-specific') AS `TABLE ACCESSED`, IFNULL(request_params.commandText, 'GET table') AS `QUERY TEXT` FROM system.access.audit WHERE user_identity.email = '{{User}}' AND action_name IN ('createTable', 'commandSubmit','getTable','deleteTable') -- AND datediff(now(), event_date) < 1 -- ORDER BY event_date DESC Query Sample Which tables did a user access?

Slide 18

Slide 18 text

©2024 Databricks Inc. — All rights reserved SELECT sku_name, usage_date, sum(usage_quantity) as `DBUs` FROM system.billing.usage WHERE month(usage_date) = month(NOW()) AND year(usage_date) = year(NOW()) GROUP BY sku_name, usage_date Query Sample How many DBUs of each SKU were used this month?

Slide 19

Slide 19 text

©2024 Databricks Inc. — All rights reserved SELECT usage_metadata.job_id as `Job ID`, sum(usage_quantity) as `DBUs` FROM system.billing.usage WHERE usage_metadata.job_id IS NOT NULL GROUP BY `Job ID` ORDER BY `DBUs` DESC Query Sample Which jobs consumed the most DBU?

Slide 20

Slide 20 text

©2024 Databricks Inc. — All rights reserved SELECT after.sku_name, before_dbus, after_dbus, ((after_dbus - before_dbus)/before_dbus * 100) AS growth_rate FROM (SELECT sku_name, sum(usage_quantity) as before_dbus FROM system.billing.usage WHERE usage_date BETWEEN "2023-04-01" and "2023-04-30" GROUP BY sku_name) as before JOIN (SELECT sku_name, sum(usage_quantity) as after_dbus FROM system.billing.usage WHERE usage_date BETWEEN "2023-05-01" and "2023-05-30" GROUP BY sku_name) as after where before.sku_name = after.sku_name SORT by growth_rate DESC Query Sample Show me the SKUs growing in usage

Slide 21

Slide 21 text

©2024 Databricks Inc. — All rights reserved SELECT sku_name, usage_unit, SUM(usage_quantity) as `DBUs consumed` FROM system.billing.usage WHERE custom_tags.{{key}} = "{{value}}" GROUP BY 1, 2 Query Sample What consumption is assigned to resources with a certain tag?

Slide 22

Slide 22 text

©2024 Databricks Inc. — All rights reserved 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 >= '2023-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; Query Sample Which cluster owners use the most DBUs?

Slide 23

Slide 23 text

©2024 Databricks Inc. — All rights reserved select sum(usage_quantity) / 400000 as dbu_used_ratio from system.billing.usage where usage_date > date_trunc("month", now()) select usage_quantity as dbu_used_ratio from system.billing.usage select sum(usage_quantity) / 400000 as dbu_used_ratio from system.billing.usage Query Sample Notification: As an administrator, I want to receive a notification if the monthly budget is about to be consumed

Slide 24

Slide 24 text

©2024 Databricks Inc. — All rights reserved The events we need are tracked with the commandSubmit, commandFinish, runCommand events (see Databrickssql logs reference for more information). Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview

Slide 25

Slide 25 text

©2024 Databricks Inc. — All rights reserved Step 1 : Activate verbose audit logs Once enabled, Databricks will populate the system.access.audit table with the events in question. We can then run the queries and create visualizations to spot areas where we need to pay more attention to reduce costs. Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview

Slide 26

Slide 26 text

©2024 Databricks Inc. — All rights reserved Step 2 : Prepare dataset SELECT event_date, user_identity.email, request_params.notebookId, request_params.clusterId, request_params.executionTime, request_params.status, request_params.commandLanguage, request_params.commandId, request_params.commandText FROM system.access.audit WHERE 1=1 AND action_name = 'runCommand' AND request_params.status NOT IN ('skipped') AND TIMESTAMPDIFF(HOUR, event_date, CURRENT_TIMESTAMP()) < 24 * 90 ORDER BY request_params.executionTime DESC SELECT action_name as `EVENT`, event_time as `WHEN`, IFNULL(request_params.full_name_arg, 'Non-specific') AS `TABLE ACCESSED`, IFNULL(request_params.commandText,'GET table') AS `QUERY TEXT` FROM system.access.audit WHERE user_identity.email like '[email protected]' AND action_name IN ('createTable', 'commandSubmit','getTable','deleteTable') AND datediff(now(), event_date) < 1 Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview

Slide 27

Slide 27 text

©2024 Databricks Inc. — All rights reserved Click on “Run” to execute the query at least once Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview Step 3 : Create dashboard

Slide 28

Slide 28 text

©2024 Databricks Inc. — All rights reserved Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview Step 3 : Create dashboard

Slide 29

Slide 29 text

©2024 Databricks Inc. — All rights reserved Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview Step 3 : Create dashboard

Slide 30

Slide 30 text

©2024 Databricks Inc. — All rights reserved Query Sample Identify long-running queries and track inefficient code running through Notebooks with System Tables and Lakeview Step 3 : Create dashboard