您可以使用 Cloud Monitoring 監控外部金鑰管理工具 (EKM) 連線。下列指標可協助您瞭解 EKM 用量:
cloudkms.googleapis.com/ekm/external/request_latencies
cloudkms.googleapis.com/ekm/external/request_count
本頁面說明如何建立資訊主頁,以追蹤與 Cloud EKM 金鑰和外部金鑰管理工具連線相關的指標,例如要求計數和延遲時間。如要進一步瞭解這些指標,請參閱 cloudkms 指標。如要進一步瞭解下列章節所述的資訊主頁建立程序,請參閱「透過 API 管理資訊主頁」。
事前準備
本頁的步驟假設您已符合以下條件:
必要的角色
如要取得使用 gcloud CLI 建立資訊主頁所需的權限,請要求管理員為您授予專案的下列 IAM 角色:
-
Monitoring 資訊主頁設定編輯器 (
roles/monitoring.dashboardEditor
) -
服務用量消費者 (
roles/serviceusage.serviceUsageConsumer
)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這些預先定義的角色包含使用 gcloud CLI 建立資訊主頁所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要使用 gcloud CLI 建立資訊主頁,您必須具備下列權限:
-
monitoring.dashboards.create
-
monitoring.dashboards.delete
-
monitoring.dashboards.update
-
serviceusage.services.use
建立資訊主頁來監控 EKM
如要監控 EKM 的狀態,請建立用於監控要求計數和延遲時間的資訊主頁:
下載資訊主頁設定:
ekm-dashboard.json
。請執行下列指令,使用設定檔建立自訂資訊主頁:
gcloud monitoring dashboards create \ --config-from-file=ekm-dashboard.json
查看 EKM 資訊主頁
在 Google Cloud 控制台中,前往「Monitoring」頁面,或使用下列按鈕:
依序選取「Resources」「Dashboards」,然後查看名為「Cloud KMS EKM」的資訊主頁。
建立 EKM 指標的快訊政策
請使用 gcloud CLI 完成下列步驟:
選取要接收 EKM 指標快訊的通知管道。
如要使用現有的通知管道,請先查看管道:
gcloud beta monitoring channels list
從清單中選擇頻道。記下通知管道 ID,後續步驟將會用到。
如要使用新的通知管道,請使用電子郵件地址建立管道:
gcloud beta monitoring channels create \ --display-name="Notification channel for EKM latency alert" \ --description="This notification channel receives EKM latency metric alerts" \ --type=email \ --channel-labels=email_address=NOTIFICATION_EMAIL
如果成功,這項指令會傳回新管道的名稱。請記下通知管道 ID,後續步驟將會用到。輸出結果會與下列內容相似:
Created notification channel [projects/PROJECT_ID/notificationChannels/NOTIFICATION_CHANNEL_ID]
使用
monitoring policies create
指令建立快訊政策:gcloud alpha monitoring policies create \ --notification-channels=NOTIFICATION_CHANNEL_ID \ --aggregation=' {"alignmentPeriod": "60s","perSeriesAligner": "ALIGN_PERCENTILE_99"}' \ --condition-display-name="EKM Request Latency > 150ms" \ --condition-filter='resource.type="cloudkms.googleapis.com/Project" metric.type="cloudkms.googleapis.com/ekm/external/request_latencies" metric.labels.ekm_service_region="LOCATION" metric.labels.method="LABEL_METHOD"' \ --duration="0s" \ --if="> 150" \ --display-name="EKM metric latency alert" \ --trigger-count=1 \ --combiner='AND'
更改下列內容:
- NOTIFICATION_CHANNEL_ID:通知管道的 ID。
- LOCATION:您要針對此指標發出警報的區域。如要不論區域一律發出快訊,請省略
metric.labels.ekm_service_region
。 - LABEL_METHOD:您要發出警示的
method
標籤,例如wrap
、unwrap
、asymmetricSign
、checkCryptoSpacePermissions
、createKey
、getInfo
或getPublicKey
。您可以使用 Metrics Explorer 探索指標標籤。