dbt Projects on Snowflake をモニターする¶
このトピックでは、モニター機能を使用して dbt Projects on Snowflake でdbtプロジェクトの実行を検査する方法(手動またはタスクスケジュール)と、ログやアーティファクトを表示する方法を説明します。
セクション |
説明 |
|---|---|
dbtプロジェクトオブジェクトと、それを実行するスケジュールされたタスクのログイベントとトレースイベントをキャプチャします。この機能を有効にするには、dbtプロジェクトオブジェクトとタスクがデプロイされるスキーマに、ログ、トレース、メトリックを設定する必要があります。 |
|
Snowsight のナビゲーションメニューで Transformation » dbt Projects を選択し、dbtプロジェクトオブジェクトの実行履歴、タスクグラフ、クエリ詳細を表示します。ワークスペースがタスクスケジュールに従って実行されるdbtプロジェクトオブジェクトに接続されると、ワークスペース内からタスク実行履歴とタスクグラフを開くことができます。 |
|
DBT_PROJECT_EXECUTION_HISTORY テーブル関数とdbtシステム関数を使用して、プログラムでdbtアーティファクトとログにアクセスします。 |
Enable monitoring features for dbt project objects¶
dbtプロジェクトオブジェクトのモニタリング機能を有効にするには、以下の SQL 例で示すように、dbtプロジェクトオブジェクトが作成されたデータベースとスキーマ上で LOG_LEVEL、TRACE_LEVEL および METRIC_LEVEL を設定します。
dbtプロジェクトオブジェクトのスケジュールされた実行を監視する¶
If you execute a deployed dbt project object on a schedule using a task, and the task is in the same schema as the dbt project object, you can view scheduled tasks directly from the workspace by selecting Connect and then View Schedules.
注釈
この機能はdbtプロジェクトオブジェクトに接続されたワークスペースでのみ利用できます。
ワークスペースからdbtプロジェクトオブジェクトのスケジュールされた実行を監視するには
From the dbt project menu on the right side of the project pane, under Scheduled runs, choose View schedules.
リストから検査するスケジュール(タスク)を選択し、View details を選択します。
The information pane for the task opens, where you can view Task details, the task Graph (if applicable), and Run History of this task. For more information, see View tasks and task graphs in Snowsight.
From the Run History for any scheduled dbt project object execution in the list, select the Open query history button on the far right to view query details, the query profile, and the query telemetry for the run. For more information, see 特定のクエリの詳細とプロファイルを確認する.
Monitor dbt project objects in Snowsight¶
To view detailed monitoring information about dbt project object executions, navigate to Transformations » dbt Projects in Snowsight. You must use a role with the MONITOR privilege to view monitoring information for the dbt project object. For more information, see Snowflakeでのdbtプロジェクトのアクセス制御.
In the navigation menu, select Transformation » dbt Projects. A histogram shows the frequency of dbt project object executions and a list of projects that have run.
The list of dbt project objects includes columns with the following information. You can filter the list by date range, command, and run status.
PROJECT - dbtプロジェクトオブジェクトの名前と、選択した期間における実行(実行)数。
LAST COMMAND - 最後の実行時に実行されたdbtコマンド。
LAST RUN STATUS - 実行の結果。Succeeded、Executing または Failed。
LAST RUN - 最後の実行からの経過時間。ソート順を逆にするには、列ヘッダーを選択します。デフォルトでは、最新の実行が最初に表示されます。
PREVIOUS RUNS - ステータスによる、選択した期間における実行の数。
DATABASE および SCHEMA - dbtプロジェクトオブジェクトが保存されるデータベースとスキーマ。
LAST RUN PARAMETERS - The dbt command-line arguments (ARGS) specified in the EXECUTE DBT PROJECT command for the last dbt project object execution.
個々のプロジェクトの実行を検査するには、リストからdbtプロジェクトオブジェクトを選択します。
The dbt project object details page in the database object explorer opens for that dbt project object.
The Run History tab is selected by default, with the following information for each job run in the selected time period:
COMMAND - 最後の実行時に実行されたdbtコマンド。
STATUS - 実行の結果。Succeeded、Executing または Failed。
RUN TIME - 最後の実行からの経過時間。ソート順を逆にするには、列ヘッダーを選択します。デフォルトでは、最新の実行が最初に表示されます。
PARAMETERS The dbt command-line arguments (ARGS) specified in the EXECUTE DBT PROJECT command for the last dbt project object execution.
To see details for a run, select it from the list.
The Query Details page opens for the EXECUTE DBT PROJECT query that ran. This page includes the following tabs:
Query Details - Displays the execution status, start time, end time, duration, warehouse size, query ID, and the SQL text of the EXECUTE DBT PROJECT command. Also shows per-model results for the dbt command that ran (for example,
build), including each model name, time taken, and status.Query Profile - Shows the query execution plan and performance statistics.
Query Telemetry - Shows telemetry data for the execution.
DAG - Visualizes the models that ran during the execution and their results. For more information, see クエリ履歴DAGの表示.
詳細については、 特定のクエリの詳細とプロファイルを確認する をご参照ください。
クエリ履歴DAGの表示¶
The Query Details for a dbt project object execution includes a DAG tab that visualizes what ran during an execution and the results for each model. This differs from the DAG on the project details page, which serves as a documentation layer for your project, including models, tests, sources, and their dependencies.
クエリ履歴DAGは、実行中に生成された manifest.json および``run_results.json`` アーティファクトから構築されます。DAGでノードを選択して、クエリIDとクエリが失敗した場合のエラーメッセージを含む、特定のクエリの詳細を表示するサイドパネルを開きます。
クエリ履歴DAGを表示するには、以下を行います。
ナビゲーションメニューで Transformations » dbt Projects を選択します。
From the list of dbt project objects, select a project.
Run History タブで、実行を選択してその実行に対する Query Details を開きます。
DAG タブを選択します。
注釈
クエリ履歴DAGで「利用可能なデータがありません」と表示された場合、実行は run_results.json が生成される前に失敗した可能性が高いです。詳細については、 クエリ履歴DAGの制限 をご参照ください。
プログラムでdbtのアーティファクトとログにアクセスする¶
DBT_PROJECT_EXECUTION_HISTORY テーブル関数と次のシステム関数を使用して、プログラムでdbtアーティファクトとログにアクセスします。
関数 |
返されるもの |
一般的な用途 |
メモ |
|---|---|---|---|
テキストログ出力(実行のログテール) |
SQL でのクイックデバッグ。たとえば、ファイルをダウンロードせずにエラーと警告を表示します。 |
ログコンテンツを返します。何も作成または移動されません。 |
|
|
LIST、GET、COPY FILES で特定のファイルを閲覧またはコピーします。 |
単なるロケーター(URL)です。相変わらず GET/COPY/FILES を実行して取得します。 |
|
単一 ZIP ファイル URL(例: |
1つのファイルをダウンロードしたい場合に便利です(例: GET を使用して)。 |
|
ログを取得して最新のdbtプロジェクトクエリの ZIP ファイルをダウンロードする¶
The following example queries Snowflake's dbt execution history to show the most recent query ID for the dbt project object. It pulls the log output for that execution and returns the location of the zipped dbt artifacts for that execution.
Snowflake CLI の例では、アーティファクトの ZIP ファイルまたは特定のファイル( manifest.json など)を GET を使ってローカルフォルダーにダウンロードします。
To download the ZIP file from Snowsight, navigate to Transformations » dbt Projects, select your project, then select an execution to navigate to Query Details, and select Download Build Artifacts under dbt Output.
You must use a role with the OWNERSHIP, USAGE, or MONITOR privilege on your dbt project objects.
Tip
Use function arguments such as DATABASE, SCHEMA, and OBJECT_NAME to filter results whenever possible. These filters are applied before the RESULT_LIMIT (default: 100 rows), so using them ensures you get the most relevant results rather than filtering a potentially truncated result set with a WHERE clause.
To view the stage path where Snowflake stored the dbt project object execution artifacts, use the
SYSTEM$LOCATE_DBT_ARTIFACTS function. You can then use that path with GET or COPY FILES with the Snowflake CLI to download
things like manifest.json, compiled SQL, or logs.
You can also create a fresh internal stage, locate the Snowflake-managed path for the specified dbt project object execution's artifacts, and copy those artifacts into your stage for retrieval, as shown in the following example: