Skip to main content
日本語は機械翻訳による参考訳です。内容に矛盾や不一致があった場合には、英語の内容が優先されます。

API 経由で Reporting Database にアクセスします

共同作成者

Cloud Insights の強力な API を使用すると、 Cognos Reporting 環境を介さずに、 Cloud Insights Reporting データベースを直接照会できます。

メモ このドキュメントでは、Cloud Insightsプレミアムエディションで使用できるCloud Insightsレポート機能について説明します。

OData

Cloud Insights レポート API は、に従います "OData v4 の" ( Open Data Protocol )レポートデータベースの照会の標準。
詳細や詳細については、をご覧ください "このチュートリアルでは" OData の場合。

すべての要求はURL _\ https://<Cloud Insights URL>/rest /v1/dwh-management/odata_で始まります

apiKey を生成します

詳細については、をご覧ください "Cloud Insights APIs の略"

API キーを生成するには、次の手順を実行します。

  • Cloud Insights 環境にログインし、 * Admin > API Access * を選択します。

  • [+API Access Token] をクリックします。

  • 名前と概要を入力します。

  • タイプには、 Data Warehouse _ を選択します。

  • 権限を読み取り / 書き込みに設定します。

  • 要望の有効期限を設定します。

  • [ 保存 ] をクリックし、 * キーをコピーして安全な場所に保存します。あとでフルキーにアクセスすることはできません。

APIkeysはに適しています 同期または非同期_

テーブルの直接クエリ

API キーを配置した状態で、 Reporting データベースの直接クエリを実行できるようになりました。長いURLは\https://<Cloud Insights URL>/rest /v1/dwh-management/odata/ではなく\https://…​/odata/に簡略化して表示することもできます

次のような簡単なクエリを試してください

  • \https://<Cloud Insights URL>/rest /v1/dwh-management/odata/dwh_custom

  • \https://<Cloud Insights URL>/rest /v1/dwh-management/odata/dwh_inventory

  • \https://<Cloud Insights URL>/rest /v1/dwh-management/odata/dwh_inventory/storage

  • \https://<Cloud Insights URL>/rest /v1/dwh-management/odata/dwh_inventory/disk

  • https://…​/odata/dwh_custom/custom_queries

REST API の例

すべての呼び出しのURLは、_\ https://<Cloud Insights URL>/rest /v1/dwh-management/odata_です。

  • get/{schema}/**-レポートデータベースからデータを取得します。

形式は、_\https://<Cloud Insights URL>/rest <schema_name>/<query>_です

 https://<domain>/rest/v1/dwh-management/odata/dwh_inventory/fabric?$count=true&$orderby=name
結果
{
   "@odata.context": "$metadata#fabric",
   "@odata.count": 2,
   "value": [
       {
           "id": 851,
           "identifier": "10:00:50:EB:1A:40:3B:44",
           "wwn": "10:00:50:EB:1A:40:3B:44",
           "name": "10:00:50:EB:1A:40:3B:44",
           "vsanEnabled": "0",
           "vsanId": null,
           "zoningEnabled": "0",
           "url": "https://<domain>/web/#/assets/fabrics/941716"
       },
       {
           "id": 852,
           "identifier": "10:00:50:EB:1A:40:44:0C",
           "wwn": "10:00:50:EB:1A:40:44:0C",
           "name": "10:00:50:EB:1A:40:44:0C",
           "vsanEnabled": "0",
           "vsanId": null,
           "zoningEnabled": "0",
           "url": "https://<domain>/web/#/assets/fabrics/941836"
        }
    ]
}

役に立つヒント

Reporting API クエリを使用する場合は、次の点に注意してください。

  • クエリペイロードには有効な JSON 文字列を指定する必要があります

  • クエリペイロードは 1 行に含める必要があります

  • 二重引用符はエスケープする必要があります。

  • タブは \t としてサポートされています

  • コメントは避けてください

  • 小文字のテーブル名がサポートされています

さらに、

  • 2 つのヘッダーが必要です。

    • 「 X-CloudInsights - apiKey 」という名前を付けます。

    • 属性値「 <apiKey> 」

API キーは Cloud Insights 環境に固有です。

同期か非同期か

デフォルトでは、APIコマンドは_synchronous_modeで動作します。つまり、要求を送信するとすぐに応答が返されます。ただし、クエリの実行に時間がかかることがあり、要求がタイムアウトする可能性があります。これを回避するには、request_asynchronously _を実行します。非同期モードでは、要求は実行の監視に使用するURLを返します。URLは準備ができたら結果を返します。

非同期モードでクエリを実行するには、ヘッダーを追加します。 Prefer: respond-async 要求に。実行が成功すると、応答に次のヘッダーが含まれます。

Status Code: 202 (which means ACCEPTED)
preference-applied: respond-async
location: https://<Cloud Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncStatus/<token>

ロケーションURLを照会すると、応答の準備ができていない場合は同じヘッダーが返され、応答の準備ができている場合はステータス200が返されます。応答コンテンツのタイプはtextで、元のクエリのhttpステータスとメタデータが含まれ、その後に元のクエリの結果が続きます。

HTTP/1.1 200 OK
 OData-Version: 4.0
 Content-Type: application/json;odata.metadata=minimal
 oDataResponseSizeCounted: true

 { <JSON_RESPONSE> }

すべての非同期クエリのリストと、準備ができているものを表示するには、次のコマンドを使用します。

 GET https://<Cloud Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncList
応答の形式は次のとおりです。
{
   "queries" : [
       {
           "Query": "https://<Cloud Insights URL>/rest/v1/dwh-management/odata/dwh_custom/heavy_left_join3?$count=true",
           "Location": "https://<Cloud Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncStatus/<token>",
           "Finished": false
       }
   ]
}