Azure Data Explorer を使用して Azure Monitor のデータのクエリを実行する

Azure Data Explorer では、Azure Data Explorer、Application Insights (AI)Log Analytics (LA) 間のクロス サービス クエリがサポートされています。 Azure Data Explorer のクエリ ツールを使用して Log Analytics または Application Insights ワークスペースに対してクロスサービス クエリでクエリを実行できます。 この記事では、クロスサービス クエリを作成する方法と、Azure Data Explorer の Web UI に Log Analytics または Application Insights のワークスペースを追加する方法について説明します。

Azure Data Explorer のクロスサービス クエリのフローは次のとおりです。

Azure Data Explorer プロキシのフローを示す図。

Azure Data Explorer クライアント ツールに Log Analytics/Application Insights ワークスペースを追加する

Log Analytics または Application Insights のワークスペースを Azure Data Explorer クライアント ツールに追加して、クラスターのクロスサービス クエリを有効にします。

  1. Log Analytics または Application Insights クラスターに接続する前に、Azure Data Explorer ネイティブ クラスター (help クラスターなど) が左側のメニューに表示されていることを確認します。

    help クラスターが Azure Data Explorer ネイティブ クラスターとして選択されている左側のメニューを示すスクリーンショット。

  2. Azure Data Explorer の UI (https://dataexplorer.azure.com/clusters) で、[クラスターの追加] を選択します。

  3. [ クラスターの追加] ウィンドウで、Log Analytics (LA) または Application Insights (AI) クラスターの URL を追加します。

    • Log Analytics (LA) の場合: https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>
    • Application Insights (AI) の場合: https://ade.applicationinsights.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>

    注意

    サブスクリプション内のすべてのデータベースを表示するには、 を指定 https://ade.applicationinsights.io/subscriptions/<subscription-id> します。 この構文は、Log Analytics クラスターでも機能します。

  4. [追加] を選択します。

    [クラスターの追加] ウィンドウを示すスクリーンショット。

    注意

    • 次のエンドポイントは異なります。
    • Azure Government- adx.monitor.azure.us/
    • Azure China- adx.monitor.azure.cn/
    • 複数の Log Analytics/Application insights ワークスペースに接続を追加する場合は、それぞれに異なる名前を付けます。 そうしないと、左側のウィンドウですべてが同じ名前になります。
  5. 接続が確立されると、Log Analytics または Application Insights のワークスペースが、ネイティブの Azure Data Explorer クラスターとともに左側のペインに表示されます。

    Log Analytics と Azure Data Explorer クラスターを示すスクリーンショット。

注意

Azure Monitor のデータに対して Azure Data Explorerから実行するクエリには、リソース間のクエリ制限が適用されます

クエリを実行する

Kusto クエリをサポートするクライアント ツールを使用してクエリを実行できます。例: Kusto Explorer、Azure Data Explorer の Web UI、Jupyter Kqlmagic、Flow、PowerQuery、PowerShell、Lens、REST API。

注意

クロスサービス クエリ機能は、データ取得のみに使用されます。 詳細については、「関数のサポート」を参照してください。

ヒント

  • データベースは、クロスサービス クエリで指定したリソースと同じ名前にする必要があります。 名前は大文字と小文字が区別されます。
  • クロスサービス クエリでは、Application Insights アプリと Log Analytics ワークスペースの名前付けが正しいことを確認してください。
  • 名前に特殊文字が含まれている場合は、クロスサービス クエリで URL エンコードに置き換えられます。
  • 名前に KQL 識別子の名前規則を満たしていない文字が含まれている場合は、ダッシュ - 文字で置き換えられます。

Azure Data Explorer クライアント ツールからの Log Analytics/Application Insights ワークスペースでの直接クエリ

Azure Data Explorer クライアント ツールから Log Analytics または Application Insights のワークスペースでクエリを実行できます。

  1. 左側のペインでワークスペースが選択されていることを確認します。

  2. 次のクエリを実行します。

Perf | take 10 // Demonstrate cross-service query on the Log Analytics workspace

Log Analytics ワークスペースのクエリを示すスクリーンショット。

Log Analytics または Application Insights のワークスペースと Azure Data Explorer ネイティブ クラスターのクロス クエリ

クロス クラスター サービス クエリを実行する場合は、左側のペインで Azure Data Explorer ネイティブ クラスターが選択されていることを確認してください。 次の例では、Azure Data Explorer クラスター テーブルと Log Analytics ワークスペースを (union を使用して) 結合する方法を示します。

次のクエリを実行します。

union StormEvents, cluster('https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>').database('<workspace-name>').Perf
| take 10
let CL1 = 'https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>';
union <ADX table>, cluster(CL1).database(<workspace-name>).<table name>

Azure Data Explorer の Web UI からのクロス サービス クエリを示すスクリーンショット。

ヒント

union の代わりに join 演算子を使用するには、それを Azure Data Explorer ネイティブ クラスターに対して実行するための hint が必要になる場合があります。

一方のテナントの Azure Data Explorer クラスターのデータを他方の Azure Monitor リソースと結合する

サービス間のクロス テナント クエリはサポートされていません。 両方のリソースにまたがるクエリを実行するためには、1 つのテナントにサインインします。

Azure Data Explorer リソースがテナント 'A' にあり、Log Analytics ワークスペースがテナント 'B' にある場合は、次の 2 つの方法のいずれかを使用します。

  1. Azure Data Explorer を使用すると、異なるテナントにプリンシパルのロールを追加できます。 Azure Data Explorer クラスターにテナント 'B' のユーザー ID を許可されているユーザーとして追加します。 Azure Data Explorer クラスター上の 'TrustedExternalTenant' プロパティにテナント 'B' が含まれていることを検証します。 テナント 'B' でクロスクエリを完全に実行します。

  2. Lighthouse を使用して、Azure Monitor リソースをテナント 'A' に射影します。

さまざまなテナントから Azure Data Explorer クラスターに接続する

Kusto Explorer では、ユーザー アカウントが最初に属しているテナントに自動的にサインインされます。 同じユーザー アカウントを使用して他のテナントのリソースにアクセスするには、接続文字列に tenantId を明示的に指定する必要があります: Data Source=https://ade.applicationinsights.io/subscriptions/SubscriptionId/resourcegroups/ResourceGroupName;Initial Catalog=NetDefaultDB;AAD Federated Security=True;Authority ID=TenantId

関数のサポート

Azure Data Explorer のクロスサービス クエリでは、Application Insights と Log Analytics の両方の関数がサポートされています。 この機能により、クロス クラスター クエリで Azure Monitor の表形式関数を直接参照できます。 次のコマンドがクロスサービス クエリでサポートされています。

  • .show functions
  • .show function {FunctionName}
  • .show database {DatabaseName} schema as json

次の図は、Azure Data Explorer の Web UI から表形式関数にクエリを実行する例を示しています。 関数を使用するには、[クエリ] ウィンドウで名前を実行します。

Azure Data Explorer の Web UI からの表形式関数のクエリの実行を示すスクリーンショット。

その他の構文例

Application Insights または Log Analytics クラスターを呼び出す場合は、次の構文オプションを使用できます。

構文の説明 Application Insights Log Analytics
このサブスクリプションで定義されているリソースのみを含むクラスター内のデータベース (クロス クラスター クエリの場合に推奨) cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>').database('<ai-app-name>) cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>').database('<workspace-name>)
このサブスクリプション内のすべてのアプリ/ワークスペースを含むクラスター cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>) cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>)
サブスクリプション内のすべてのアプリ/ワークスペースを含み、このリソース グループのメンバーであるクラスター cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>) cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>)
このサブスクリプションで定義されているリソースのみを含むクラスター cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>) cluster(''https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>)
UsGov のエンドポイントの場合 cluster(''https://adx.monitor.azure.us/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>)
China 21Vianet のエンドポイントの場合 cluster(''https://adx.monitor.azure.cn/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>)