如何找出與 API Gateway API 金鑰相關的使用情況?

1 分的閱讀內容
0

我想取得與 Amazon API Gateway API 金鑰相關的使用情況。

解決方法

依照下列指示,使用 AWS 管理主控台或 AWS Command Line Interface (AWS CLI) 取得 API 金鑰使用情況。

**注意:**如果您在執行 AWS CLI 命令時收到錯誤,請確認您使用的是最新版本的 AWS CLI

使用 AWS 管理主控台

  1. 開啟 API Gateway 主控台
  2. 在導覽窗格中,選擇 API
  3. 選擇您的 API,然後選擇用量計畫
  4. 選擇您的用量計畫
  5. 選擇動作,然後選擇匯出用量資料
  6. 選擇匯出的開始時間結束時間日期範圍。
  7. 匯出為中,選擇 JSONCSV,然後選擇匯出

如需詳細資訊,請參閱 Create, configure, and test usage plans with the API Gateway console

使用 AWS CLI

您可以使用 AWS CLI 命令 get-usage,取得某日期範圍內,用量計畫的用量資料,類似於以下內容:

aws apigateway get-usage --usage-plan-id <usage-plan-id> --start-date "20xx-xx-xx" --end-date "20xx-xx-xx" --key-id <api-key-id>

**注意:**用量日期範圍不能超過 90 天。

如需詳細資訊,請參閱 Create, configure, and test usage plans using the API Gateway CLI and REST API

相關資訊

API 金鑰和用量方案的最佳實務

AWS 官方
AWS 官方已更新 7 個月前