Edge API を使って、カスタム レポートを 1 つの組織環境から別の組織環境にエクスポートおよびインポートできます。この方法を使用すると、お好みのカスタム レポート デザインをさまざまな組織と環境で再利用できます。さらに、デザイン(シンプルな JSON テキスト ファイル)を CSV に保存することもできます。
まず、Lists analytics report definitions API を使用して、組織に定義されているすべてのレポートの UUID を取得します。
curl -X GET "https://api.enterprise.apigee.com/v1/organizations/org-name/reports" \ -u email:password
次のように、出力にはレポートごとの表示名(Edge UI に表示される名前)と UUID が示されます。
{
"qualifier": [
{
"displayName": "My Report 1",
"name": "cb7cd16a-44c4-0bc83c3b9c92"
},
{
"displayName": "My Other Report",
"name": "a7e3fc4e-992a2ffc0e3d49d"
},
...
]
}次は、Get an analytics report definition API で、対象のレポートの UUID を使用してレポートの定義を取得します。次の例では、「My Report 1」という名前のレポートの定義を取得します。
curl -X GET "https://api.enterprise.apigee.com/v1/organizations/org-name/reports/cb7cd16a-44c4-0bc83c3b9c92" \ -u email:password
出力にレポート定義が示されます。
{
"chartType": "column",
"comments": [],
"createdAt": 1506922614000,
"createdBy": "11.111.121.57",
"dimensions": [
"apiproxy",
"proxy_pathsuffix",
"proxy_client_ip"
],
"displayName": "My Report 1",
"environment": "prod",
"lastModifiedAt": 1512435450000,
"lastModifiedBy": "111.111.121.57",
"lastViewedAt": 1512435450000,
"metrics": [
{
"function": "avg",
"name": "response_size"
},
{
"function": "avg",
"name": "request_size"
}
],
"name": "cb7cd16a-44c4-0bc83c3b9c92",
"organization": "myOrg",
"properties": [
{
"property": "__ui__",
"value": [
{
"name": "description"
},
{
"name": "accuracy"
}
]
}
],
"sortbyCols": [],
"tags": [],
"timeUnit": "hour"
}JSON 出力をコピーし、インポート先に応じて environment フィールドと organization フィールドを更新し、Create an analytics report definition API を使用して定義をインポートします。
たとえば、destOrg という組織の test 環境にレポート定義をインポートするには、次のようにします。
curl -X POST -H "Content-Type: application/json" "https://api.enterprise.apigee.com/v1/organizations/destOrg/reports" \
-d "{
"chartType": "column",
"comments": [],
"createdAt": 1506922614000,
"createdBy": "11.111.121.57",
"dimensions": [
"apiproxy",
"proxy_pathsuffix",
"proxy_client_ip"
],
"displayName": "My Report 1",
"environment": "test",
"lastModifiedAt": 1512435450000,
"lastModifiedBy": "111.111.121.57",
"lastViewedAt": 1512435450000,
"metrics": [
{
"function": "avg",
"name": "response_size"
},
{
"function": "avg",
"name": "request_size"
}
],
"name": "cb7cd16a-44c4-0bc83c3b9c92",
"organization": "destOrg",
"properties": [
{
"property": "__ui__",
"value": [
{
"name": "description"
},
{
"name": "accuracy"
}
]
}
],
"sortbyCols": [],
"tags": [],
"timeUnit": "hour"
}" \
-u email:password これで、Edge UI でこの組織に関するレポートを表示できるようになります。