监控 Cloud Functions 的 App Check 请求指标
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将 App Check SDK 添加到应用后,您应在启用 App Check 强制执行之前,先确保这样做不会干扰现有的合法用户。
对于 Cloud Functions,您可以通过检查函数的日志来获取 App Check 指标。每次调用 Callable 函数时,系统都会发送一项结构化日志条目,如下所示:
{
"severity": "INFO", // INFO, WARNING, or ERROR
"logging.googleapis.com/labels": {"firebase-log-type": "callable-request-verification"},
"jsonPayload": {
"message": "Callable header verifications passed.",
"verifications": {
// ...
"app": "MISSING", // VALID, INVALID, or MISSING
}
}
}
您可以通过使用以下指标过滤条件创建基于日志的计数器指标,在 Google Cloud 控制台中分析这些指标:
resource.type="cloud_function"
resource.labels.function_name="YOUR_CLOUD_FUNCTION"
resource.labels.region="us-central1"
labels.firebase-log-type="callable-request-verification"
使用 jsonPayload.verifications.appCheck
字段为指标添加标签。
后续步骤
在了解 App Check 对用户有何影响并为后续操作做好准备之后,您便可以为 Cloud Functions 启用 App Check 强制执行。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-12。
[null,null,["最后更新时间 (UTC):2025-08-12。"],[],[],null,["After you add the App Check SDK to your app, but before you enable\nApp Check enforcement, you should make sure that doing so won't disrupt your\nexisting legitimate users.\n\nFor Cloud Functions, you can get App Check metrics by examining your\nfunctions' logs. Every invocation of a callable function emits a structured log\nentry like the following example: \n\n {\n \"severity\": \"INFO\", // INFO, WARNING, or ERROR\n \"logging.googleapis.com/labels\": {\"firebase-log-type\": \"callable-request-verification\"},\n \"jsonPayload\": {\n \"message\": \"Callable header verifications passed.\",\n \"verifications\": {\n // ...\n \"app\": \"MISSING\", // VALID, INVALID, or MISSING\n }\n }\n }\n\nYou can analyze these metrics in the Google Cloud console by [creating a\nlogs-based counter metric](https://cloud.google.com/logging/docs/logs-based-metrics/counter-metrics)\nwith the following metric filter: \n\n```\nresource.type=\"cloud_function\"\nresource.labels.function_name=\"YOUR_CLOUD_FUNCTION\"\nresource.labels.region=\"us-central1\"\nlabels.firebase-log-type=\"callable-request-verification\"\n```\n\n[Label the metric](https://cloud.google.com/logging/docs/logs-based-metrics/labels#create-label)\nusing the field `jsonPayload.verifications.appCheck`.\n\nNext steps\n\nWhen you understand how App Check will affect your users and you're ready to\nproceed, you can [enable App Check enforcement](/docs/app-check/cloud-functions)\nfor Cloud Functions."]]