您目前查看的是 Apigee Edge 說明文件。
前往 Apigee X 說明文件。 info
您可以透過 Edge API,將自訂報表從一個機構環境匯出,再匯入另一個環境。 這項實用技巧可讓您在不同機構和環境中,重複使用喜歡的自訂報表設計。此外,您也可以在 CSV 中儲存設計 (簡單的 JSON 文字檔)。
首先,請使用「清單分析報表定義」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"
},
...
]
}現在,請使用所需報表的 UUID 呼叫「取得 Analytics 報表定義」API,擷取報表定義。在本例中,您會取得名為「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 欄位,然後使用「建立 Analytics 報表定義」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 中看到報表。