サーバーサイドの自動化を使用してマルチリージョン リネージを検索する

searchLineageStreaming API を使用すると、マルチレベルのクロスリージョン データリネージを検索し、統合グラフをリアルタイム ストリームとして受信できます。リクエスト タイムアウトなしで、広範、詳細、またはマルチプロジェクトのデータ アーキテクチャを走査するツールを構築できます。詳細については、マルチリージョン リネージ検索についてをご覧ください。

主な機能

searchLineageStreaming API には次の機能が含まれています。

  • 幅優先探索: 定義されたルート エンティティのセットから上流または下流にリネージグラフをレイヤごとに走査し、接続された各アセットの深さを正確に計算します。

  • ストリーミング レスポンス: バックエンド システムがサブグラフとリネージリンクを検出すると、それらを含むチャンク化されたレスポンスをリアルタイムで配信します。大規模なマルチプロジェクト グラフでタイムアウトする可能性がある標準のリネージ ルックアップ API とは異なり、ストリーミングでは、広範なグラフや深いグラフでリクエストのタイムアウトが発生しません。

  • マルチロケーションとマルチプロジェクトのトラバーサル: リクエストパスで指定する課金プロジェクトは 1 つだけですが、必要な権限があれば、API は複数の Google Cloud プロジェクトと地理的なロケーションにわたるリネージリンクを自動的に検出してトラバースします。

  • きめ細かい列レベルのリネージ: アセット間の列レベルの依存関係の検索をサポートします。

  • ワイルドカード ルックアップ: 完全修飾名(FQN)の末尾に * を付けることで、特定のエンティティのすべての列レベルのリネージを取得できます。

  • パイプライン分析情報: リネージリンクを作成した変換パイプライン(プロセス)に関するメタデータを取得します(省略可)。

始める前に

API にリクエストを送信する前に、次のセキュリティと環境の前提条件を満たしていることを確認してください。

必要なロール

データリネージ リンクを検索するために必要な権限を取得するには、リネージリンクとプロセスが保存されているプロジェクトに対するデータリネージ閲覧者 (roles/datalineage.viewer)IAM ロールを付与するよう管理者に依頼してください。ロールの付与については、プロジェクト、フォルダ、組織に対するアクセス権の管理をご覧ください。

この事前定義ロールには、データリネージ リンクを検索するために必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。

必要な権限

データリネージ リンクを検索するには、次の権限が必要です。

  • エンティティ レベルのリネージを検索する: リンクが保存されているプロジェクトに対する datalineage.events.get
  • 列レベルのリネージを検索する: リンクが保存されているプロジェクトに対する datalineage.events.getFields
  • パイプライン プロセスの詳細をすべて取得する: プロセスが保存されているプロジェクトに対する datalineage.processes.get

カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。

リソースのスコープ設定

API リクエストを構成するときは、管理請求に使用されるリソースと、API によってスキャンされる実際のロケーションを区別する必要があります。

  • 課金親パス: URL リクエストの parent パスは、projects/project/locations/location 形式にする必要があります。この特定のプロジェクトとロケーションのペアは、課金割り当てと API レート制限の評価にのみ使用されます。

  • 対象地域: リクエスト本文の locations 配列で、バックエンドでスキャンするリージョンを明示的に定義します。

認証の設定

curl コマンドを認証するために、 Google Cloud アクセス トークンを使用して環境変数を初期化します。

export ACCESS_TOKEN=$(gcloud auth print-access-token)

使用例

次の例では、エンドポイント datalineage.googleapis.com を使用します。

マルチレベル、マルチプロジェクトのリネージを検索する

グラフの複数の深度を走査し、異なる Google Cloud プロジェクトをスキャンするディープ リネージ検索を実行するには、次の変数を定義します。

  • limits.maxDepth をターゲット トラバーサル深度に設定します(1 から 100 までの値を使用できます)。

  • locations 配列に、バックエンドが相互参照するターゲット リージョン(["us", "us-east1"] など)を入力します。

C#

C#

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある C# の設定手順を行ってください。 詳細については、Data Lineage C# API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

using Google.Api.Gax.Grpc;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.DataCatalog.Lineage.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedLineageClientSnippets
{
    /// <summary>Snippet for SearchLineageStreaming</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task SearchLineageStreamingRequestObject()
    {
        // Create client
        LineageClient lineageClient = LineageClient.Create();
        // Initialize request argument(s)
        SearchLineageStreamingRequest request = new SearchLineageStreamingRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Locations = { "", },
            RootCriteria = new SearchLineageStreamingRequest.Types.RootCriteria(),
            Direction = SearchLineageStreamingRequest.Types.SearchDirection.Unspecified,
            Filters = new SearchLineageStreamingRequest.Types.SearchFilters(),
            Limits = new SearchLineageStreamingRequest.Types.SearchLimits(),
        };
        // Make the request, returning a streaming response
        using LineageClient.SearchLineageStreamingStream response = lineageClient.SearchLineageStreaming(request);

        // Read streaming responses from server until complete
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<SearchLineageStreamingResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            SearchLineageStreamingResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    }
}

Java

Java

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Java の設定手順を行ってください。 詳細については、Data Lineage Java API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

import com.google.api.gax.rpc.ServerStream;
import com.google.cloud.datacatalog.lineage.v1.LineageClient;
import com.google.cloud.datacatalog.lineage.v1.LocationName;
import com.google.cloud.datacatalog.lineage.v1.SearchLineageStreamingRequest;
import com.google.cloud.datacatalog.lineage.v1.SearchLineageStreamingResponse;
import java.util.ArrayList;

public class AsyncSearchLineageStreaming {

  public static void main(String[] args) throws Exception {
    asyncSearchLineageStreaming();
  }

  public static void asyncSearchLineageStreaming() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (LineageClient lineageClient = LineageClient.create()) {
      SearchLineageStreamingRequest request =
          SearchLineageStreamingRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .addAllLocations(new ArrayList<String>())
              .setRootCriteria(SearchLineageStreamingRequest.RootCriteria.newBuilder().build())
              .setFilters(SearchLineageStreamingRequest.SearchFilters.newBuilder().build())
              .setLimits(SearchLineageStreamingRequest.SearchLimits.newBuilder().build())
              .build();
      ServerStream<SearchLineageStreamingResponse> stream =
          lineageClient.searchLineageStreamingCallable().call(request);
      for (SearchLineageStreamingResponse response : stream) {
        // Do something when a response is received.
      }
    }
  }
}

Node.js

Node.js

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Node.js の設定手順を行ってください。 詳細については、Data Lineage Node.js API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The project and location to initiate the search from.
 */
// const parent = 'abc123'
/**
 *  Required. The locations to search in.
 */
// const locations = ['abc','def']
/**
 *  Required. Criteria for the root of the search.
 */
// const rootCriteria = {}
/**
 *  Required. Direction of the search.
 */
// const direction = {}
/**
 *  Optional. Filters for the search.
 */
// const filters = {}
/**
 *  Optional. Limits for the search.
 */
// const limits = {}

// Imports the Lineage library
const {LineageClient} = require('@google-cloud/lineage').v1;

// Instantiates a client
const lineageClient = new LineageClient();

async function callSearchLineageStreaming() {
  // Construct request
  const request = {
    parent,
    locations,
    rootCriteria,
    direction,
  };

  // Run request
  const stream = await lineageClient.searchLineageStreaming(request);
  stream.on('data', (response) => { console.log(response) });
  stream.on('error', (err) => { throw(err) });
  stream.on('end', () => { /* API call completed */ });
}

callSearchLineageStreaming();

Python

Python

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Python の設定手順を行ってください。 詳細については、Data Lineage Python API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import datacatalog_lineage_v1


def sample_search_lineage_streaming():
    # Create a client
    client = datacatalog_lineage_v1.LineageClient()

    # Initialize request argument(s)
    request = datacatalog_lineage_v1.SearchLineageStreamingRequest(
        parent="parent_value",
        locations=["locations_value1", "locations_value2"],
        direction="UPSTREAM",
    )

    # Make the request
    stream = client.search_lineage_streaming(request=request)

    # Handle the response
    for response in stream:
        print(response)

Ruby

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Ruby の設定手順を行ってください。 詳細については、Data Lineage Ruby API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/data_catalog/lineage/v1"

##
# Snippet for the search_lineage_streaming call in the Lineage service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client#search_lineage_streaming.
#
def search_lineage_streaming
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::DataCatalog::Lineage::V1::SearchLineageStreamingRequest.new

  # Call the search_lineage_streaming method to start streaming.
  output = client.search_lineage_streaming request

  # The returned object is a streamed enumerable yielding elements of type
  # ::Google::Cloud::DataCatalog::Lineage::V1::SearchLineageStreamingResponse
  output.each do |current_response|
    p current_response
  end
end

REST

データリネージを検索するには、searchLineageStreaming メソッドを使用します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 管理用の課金と割り当ての評価に使用される Google Cloud プロジェクト ID。
  • LOCATION_ID: Google Cloud ロケーション(us-central1 など)。
  • SOURCE_PROJECT_ID: ソーステーブルが配置されている Google Cloud プロジェクトの ID。
  • DATASET_ID: BigQuery データセット ID。
  • TABLE_ID: BigQuery テーブル ID。

HTTP メソッドと URL:

POST https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID:searchLineageStreaming

リクエストの本文(JSON):

{
  "parent": "projects/PROJECT_ID/locations/LOCATION_ID",
  "locations": [
    "LOCATION_ID",
    "us-east1",
    "us-central1"
  ],
  "rootCriteria": {
    "entities": {
      "entities": [
        {
          "fullyQualifiedName": "bigquery:SOURCE_PROJECT_ID.DATASET_ID.TABLE_ID"
        }
      ]
    }
  },
  "direction": "DOWNSTREAM",
  "limits": {
    "maxDepth": 10,
    "maxResults": 5000
  }
}

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "links": [
    {
      "source": {
        "fullyQualifiedName": "bigquery:project-prod.dataset.source_table"
      },
      "target": {
        "fullyQualifiedName": "bigquery:project-prod.dataset.target_table"
      },
      "depth": 1,
      "location": "us"
    }
  ]
}

複数の地理的位置を検索する

locations 繰り返し配列フィールドに渡される地理的リージョンを変更することで、リネージグラフのスキャンを制限または拡張できます。

C#

C#

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある C# の設定手順を行ってください。 詳細については、Data Lineage C# API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

using Google.Api.Gax.Grpc;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.DataCatalog.Lineage.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedLineageClientSnippets
{
    /// <summary>Snippet for SearchLineageStreaming</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task SearchLineageStreamingRequestObject()
    {
        // Create client
        LineageClient lineageClient = LineageClient.Create();
        // Initialize request argument(s)
        SearchLineageStreamingRequest request = new SearchLineageStreamingRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Locations = { "", },
            RootCriteria = new SearchLineageStreamingRequest.Types.RootCriteria(),
            Direction = SearchLineageStreamingRequest.Types.SearchDirection.Unspecified,
            Filters = new SearchLineageStreamingRequest.Types.SearchFilters(),
            Limits = new SearchLineageStreamingRequest.Types.SearchLimits(),
        };
        // Make the request, returning a streaming response
        using LineageClient.SearchLineageStreamingStream response = lineageClient.SearchLineageStreaming(request);

        // Read streaming responses from server until complete
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<SearchLineageStreamingResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            SearchLineageStreamingResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    }
}

Java

Java

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Java の設定手順を行ってください。 詳細については、Data Lineage Java API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

import com.google.api.gax.rpc.ServerStream;
import com.google.cloud.datacatalog.lineage.v1.LineageClient;
import com.google.cloud.datacatalog.lineage.v1.LocationName;
import com.google.cloud.datacatalog.lineage.v1.SearchLineageStreamingRequest;
import com.google.cloud.datacatalog.lineage.v1.SearchLineageStreamingResponse;
import java.util.ArrayList;

public class AsyncSearchLineageStreaming {

  public static void main(String[] args) throws Exception {
    asyncSearchLineageStreaming();
  }

  public static void asyncSearchLineageStreaming() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (LineageClient lineageClient = LineageClient.create()) {
      SearchLineageStreamingRequest request =
          SearchLineageStreamingRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .addAllLocations(new ArrayList<String>())
              .setRootCriteria(SearchLineageStreamingRequest.RootCriteria.newBuilder().build())
              .setFilters(SearchLineageStreamingRequest.SearchFilters.newBuilder().build())
              .setLimits(SearchLineageStreamingRequest.SearchLimits.newBuilder().build())
              .build();
      ServerStream<SearchLineageStreamingResponse> stream =
          lineageClient.searchLineageStreamingCallable().call(request);
      for (SearchLineageStreamingResponse response : stream) {
        // Do something when a response is received.
      }
    }
  }
}

Node.js

Java

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Java の設定手順を行ってください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The project and location to initiate the search from.
 */
// const parent = 'abc123'
/**
 *  Required. The locations to search in.
 */
// const locations = ['abc','def']
/**
 *  Required. Criteria for the root of the search.
 */
// const rootCriteria = {}
/**
 *  Required. Direction of the search.
 */
// const direction = {}
/**
 *  Optional. Filters for the search.
 */
// const filters = {}
/**
 *  Optional. Limits for the search.
 */
// const limits = {}

// Imports the Lineage library
const {LineageClient} = require('@google-cloud/lineage').v1;

// Instantiates a client
const lineageClient = new LineageClient();

async function callSearchLineageStreaming() {
  // Construct request
  const request = {
    parent,
    locations,
    rootCriteria,
    direction,
  };

  // Run request
  const stream = await lineageClient.searchLineageStreaming(request);
  stream.on('data', (response) => { console.log(response) });
  stream.on('error', (err) => { throw(err) });
  stream.on('end', () => { /* API call completed */ });
}

callSearchLineageStreaming();

Python

Python

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Python の設定手順を行ってください。 詳細については、Data Lineage Python API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import datacatalog_lineage_v1


def sample_search_lineage_streaming():
    # Create a client
    client = datacatalog_lineage_v1.LineageClient()

    # Initialize request argument(s)
    request = datacatalog_lineage_v1.SearchLineageStreamingRequest(
        parent="parent_value",
        locations=["locations_value1", "locations_value2"],
        direction="UPSTREAM",
    )

    # Make the request
    stream = client.search_lineage_streaming(request=request)

    # Handle the response
    for response in stream:
        print(response)

Ruby

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Ruby の設定手順を行ってください。 詳細については、Data Lineage Ruby API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/data_catalog/lineage/v1"

##
# Snippet for the search_lineage_streaming call in the Lineage service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client#search_lineage_streaming.
#
def search_lineage_streaming
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::DataCatalog::Lineage::V1::SearchLineageStreamingRequest.new

  # Call the search_lineage_streaming method to start streaming.
  output = client.search_lineage_streaming request

  # The returned object is a streamed enumerable yielding elements of type
  # ::Google::Cloud::DataCatalog::Lineage::V1::SearchLineageStreamingResponse
  output.each do |current_response|
    p current_response
  end
end

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 管理用の課金と割り当ての評価に使用される Google Cloud プロジェクト ID。
  • LOCATION_ID: Google Cloud ロケーション(us-central1 など)。
  • SOURCE_PROJECT_ID: ソーステーブルが配置されている Google Cloud プロジェクトの ID。
  • DATASET_ID: BigQuery データセット ID。
  • TABLE_ID: BigQuery テーブル ID。

HTTP メソッドと URL:

POST https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID:searchLineageStreaming

リクエストの本文(JSON):

{
  "parent": "projects/PROJECT_ID/locations/LOCATION_ID",
  "locations": [
    "LOCATION_ID",
    "us-east1",
    "us-central1"
  ],
  "rootCriteria": {
    "entities": {
      "entities": [
        {
          "fullyQualifiedName": "bigquery:SOURCE_PROJECT_ID.DATASET_ID.TABLE_ID"
        }
      ]
    }
  },
  "direction": "DOWNSTREAM",
  "limits": {
    "maxDepth": 10,
    "maxResults": 5000
  }
}

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "links": [
    {
      "source": {
        "fullyQualifiedName": "bigquery:project-prod.dataset.source_table"
      },
      "target": {
        "fullyQualifiedName": "bigquery:project-prod.dataset.target_table"
      },
      "depth": 1,
      "location": "us"
    }
  ]
}

デフォルトでは、API はプロセス情報を省略します(maxProcessPerLink のデフォルトは 0)。データリンクを作成したパイプラインのリソース名を取得するには、limits.maxProcessPerLink をゼロ以外の正の整数に構成します。

次に例を示します。

Java

Java

このサンプルを試す前に、クライアント ライブラリを使用した Data Lineage のクイックスタートにある Java の設定手順を行ってください。 詳細については、Data Lineage Java API のリファレンス ドキュメントをご覧ください。

データリネージへの認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

import com.google.cloud.datacatalog.lineage.v1.LineageClient;
import com.google.cloud.datacatalog.lineage.v1.Process;
import com.google.cloud.datacatalog.lineage.v1.ProcessName;

public class SyncGetProcessProcessname {

  public static void main(String[] args) throws Exception {
    syncGetProcessProcessname();
  }

  public static void syncGetProcessProcessname() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (LineageClient lineageClient = LineageClient.create()) {
      ProcessName name = ProcessName.of("[PROJECT]", "[LOCATION]", "[PROCESS]");
      Process response = lineageClient.getProcess(name);
    }
  }
}

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • BILLING_PROJECT_ID: 管理用の課金と割り当ての評価に使用される Google Cloudプロジェクト。プロジェクト番号またはプロジェクト ID を指定します。
  • LOCATION_ID: リネージ検索が実行される Google Cloud ロケーション。
  • FULLY_QUALIFIED_NAME: ターゲット エンティティの完全修飾名(FQN)。bigquery:PROJECT_ID.DATASET_ID.TABLE_ID の形式。

HTTP メソッドと URL:

POST https://datalineage.googleapis.com/v1/projects/BILLING_PROJECT_ID/locations/LOCATION_ID:searchLineageStreaming

リクエストの本文(JSON):

{
  "parent": "projects/BILLING_PROJECT_ID/locations/LOCATION_ID",
  "locations": [
    "LOCATION_ID"
  ],
  "rootCriteria": {
    "entities": {
      "entities": [
        {
          "fullyQualifiedName": "FULLY_QUALIFIED_NAME"
        }
      ]
    }
  },
  "direction": "UPSTREAM",
  "limits": {
    "maxProcessPerLink": 5
  }
}

リクエストを送信するには、次のいずれかのオプションを展開します。

 

レスポンスの動作: 結果のストリームは、絶対システム リソース名(projects/my-project/locations/us/processes/my-process など)のみを含むプロセス メッセージを links[].processes フィールドに入力します。

FieldMask を使用してプロセスの詳細をすべて取得する

リソース名だけでなく、パイプラインに関する完全な構造メタデータ(displayName、システム attributes、実行 origin など)が必要な場合は、API FieldMask を使用する必要があります。

  1. limits.maxProcessPerLink にゼロ以外の値を指定します。

  2. URL パスに fields クエリ パラメータを追加し、他の必須フィールドとともに links.processes.process を指定します。

次に例を示します。

curl -H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-X POST "https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming?fields=links.processes.process,links.source,links.target,links.depth" \
--data '{
  "parent": "projects/my-billing-project/locations/us",
  "locations": ["us"],
  "rootCriteria": {
    "entities": {
      "entities": [{
        "fullyQualifiedName": "bigquery:my-project.dataset.target_table"
      }]
    }
  },
  "direction": "UPSTREAM",
  "limits": {
    "maxProcessPerLink": 5
  }
}'

テーブルレベルと列レベルの両方のリネージを検索する

rootCriteria.entities.entities リストに複数のエンティティを指定することで、1 つのリクエストでテーブルレベル(アセットレベル)と列レベル(フィールドレベル)の両方のリネージを検索できます。

  • テーブルレベルのリネージの場合は、field 配列を省略します。

  • 列レベルのリネージの場合は、field 配列に 1 つの列を指定します。

次に例を示します。

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -X POST https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming \
     --data '{
       "parent": "projects/my-billing-project/locations/us",
       "locations": ["us"],
       "rootCriteria": {
         "entities": {
           "entities": [
             {
               "fullyQualifiedName": "bigquery:my-project.dataset.table_a"
             },
             {
               "fullyQualifiedName": "bigquery:my-project.dataset.table_b",
               "field": ["email"]
             }
           ]
         }
       },
       "direction": "DOWNSTREAM"
     }'

列レベルのリネージにワイルドカードを使用する

すべての列を個別にリストすることなく、特定のテーブルで使用可能なすべての列レベルのリネージを検索するには、field 配列の単一の値としてワイルドカード文字 * を使用します。

次に例を示します。

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -X POST https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming \
     --data '{
       "parent": "projects/my-billing-project/locations/us",
       "locations": ["us"],
       "rootCriteria": {
         "entities": {
           "entities": [{
             "fullyQualifiedName": "bigquery:my-project.dataset.my_table",
             "field": ["*"]
           }]
         }
       },
       "direction": "DOWNSTREAM"
     }'

リネージ結果をフィルタする

リクエスト本文の filters ブロックを使用して、リネージ検索結果を絞り込むことができます。

依存関係のタイプでフィルタする

結果を特定の依存関係タイプ(直接コピー(EXACT_COPY)や、フィルタリングやグループ化などの変換(OTHER))に制限するには、dependencyTypes フィルタを使用します。

次に例を示します。

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -X POST https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming \
     --data '{
       "parent": "projects/my-billing-project/locations/us",
       "locations": ["us"],
       "rootCriteria": {
         "entities": {
           "entities": [{
             "fullyQualifiedName": "bigquery:my-project.dataset.my_table"
           }]
         }
       },
       "direction": "DOWNSTREAM",
       "filters": {
         "dependencyTypes": ["EXACT_COPY"]
       }
     }'

検索でテーブルレベルのリネージのみが返され、列レベルのリネージが完全に除外されるようにするには、entitySet フィルタを ENTITIES に設定します。

次に例を示します。

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -X POST https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming \
     --data '{
       "parent": "projects/my-billing-project/locations/us",
       "locations": ["us"],
       "rootCriteria": {
         "entities": {
           "entities": [{
             "fullyQualifiedName": "bigquery:my-project.dataset.my_table"
           }]
         }
       },
       "direction": "DOWNSTREAM",
       "filters": {
         "entitySet": "ENTITIES"
       }
     }'

期間でフィルタ

リネージの検索結果を特定の期間に制限できます。

たとえば、特定のタイムスタンプの後に作成されたリネージデータを検索するには、次のリクエストを使用します。

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -X POST https://datalineage.googleapis.com/v1/projects/my-billing-project/locations/us:searchLineageStreaming \
     --data '{
       "parent": "projects/my-billing-project/locations/us",
       "locations": ["us"],
       "rootCriteria": {
         "entities": {
           "entities": [{
             "fullyQualifiedName": "bigquery:my-project.dataset.my_table"
           }]
         }
       },
       "direction": "DOWNSTREAM",
       "filters": {
         "timeRange": {
           "startTime": "2026-01-01T00:00:00Z"
         }
       }
     }'

トラブルシューティング: 到達不能なロケーションと部分的なグラフを処理する

ストリーミング API は、分散されたプロジェクトとロケーションのセットを同時にスキャンするため、実行中に一部のリモート リージョンが一時的に停止したり、通信不能になったり、構成が誤ったりすることがあります。

  • 症状: 返されたリネージグラフのレイアウトが不完全であるか、想定されるリージョン ホップが欠落している。

  • 診断: データの完全性を保護するため、searchLineageStreamingResponse ストリームは、projects/PROJECT_NUMBER/locations/LOCATION 形式(例: projects/123456789/locations/us-east1)を使用して、問題のある場所を専用の unreachable フィールド(繰り返し文字列)に入力します。

  • ベスト プラクティス: グラフを処理する前に、unreachable フィールドを検査してデータの完全性を検証するようにクライアント アプリケーションを構築します。

次のステップ