Firebase 電話號碼驗證可觀測性

Firebase PNV 可與 Cloud Monitoring 和 Cloud Logging 整合。

Google Cloud Monitoring

Firebase PNV 會匯出單一指標 fpnv.googleapis.com/verification_count,並附上 methodoutcomesms_region 標籤:

指標類型 推出階段(資源階層層級)
顯示名稱
種類、類型、單位
受監控資源
說明
標籤
fpnv.googleapis.com/verification_count BETA 版(專案)
Firebase Phone Number Verification 指標
DELTAINT641
fpnv.googleapis.com/App
電話號碼驗證嘗試次數。
method: 使用的驗證方法。一律API
outcome: 驗證嘗試的結果 (SUCCESSFAILUREQUOTA_EXCEEDEDBACKEND_ERROR)。
sms_region: 要求來源區域。

Google Cloud Logging

您可以使用 Cloud Logging 取得特定電話號碼驗證要求的詳細資訊。每次嘗試驗證電話號碼時,系統都會發出結構化記錄項目:

記錄 ID:fpnv.googleapis.com/verifications

{
  "resource": {
    "type": "fpnv.googleapis.com/App",
    "labels": [
      "resource_container": /* Your Firebase / Google Cloud project ID: "project/your-project-id" */,
      "app_id": /* The ID of a Firebase app within your project  */
    ]
  },
  "severity": /* DEBUG (for successful verification) or WARNING (for failed verification) */,
  "jsonPayload": {
    "method": /* The method used for the verification attempt: METHOD_UNSPECIFIED, API */,
    "outcome": /* The final outcome of the verification attempt: OUTCOME_UNSPECIFIED, SUCCESS, FAILURE, QUOTA_EXCEEDED, BACKEND_ERROR, DEVICE_INTEGRITY_FAILURE */,
    "nonce": /* Unique ID for the verification attempt, provided to the SDK by the client if using API verification. */,
    "response_code": /* The HTTP response code returned to the client, if the interaction was over HTTP. */,
    "sms_region_code": /* The region from which the request originated. */,
    "error_code": /* A specific error code from the underlying verification service or provider, if available. */,
    "error_message": /* A message describing why the verification failed, if applicable. */
  }
}

舉例來說,如要找出所有源自特定應用程式且因任何原因而失敗的 API 驗證嘗試記錄,請執行下列步驟:

log_id("fpnv.googleapis.com/verifications") AND
resource.type="fpnv.googleapis.com/App" AND
resource.labels.app_id="Your Firebase app ID" AND
severity>=WARNING AND
jsonPayload.method:"API"