Go 1.11 已达到支持终止期限,将于 2026 年 1 月 31 日
弃用。弃用后,您将无法部署 Go 1.11 应用,即使您的组织之前曾使用组织政策重新启用旧版运行时的部署也是如此。现有的 Go 1.11 应用在
弃用日期之后将继续运行并接收流量。我们建议您
迁移到最新支持的 Go 版本。
监控和提醒延迟时间
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍如何在 Google App Engine 中监控延迟时间以及获取有关延迟时间增加的提醒。
App Engine 应用的延迟时间较长可能有多种原因。例如,应用没有优化代码、资源不足、机器忙碌等等。本指南重点介绍 App Engine 导致的延迟时间,无论原因如何。
请务必注意,较长的延迟时间通常会导致 5xx 错误。因此,快速检测较长的延迟时间可帮助您及时采取行动,从而解决应用错误。
设置监控和提醒
监控
如果要创建自定义图表来监控应用的响应延迟时间,请使用 Cloud Monitoring > Metrics Explorer 构建您自己的图表。
前往 Metrics Explorer 页面
在资源类型中,选择“GAE 应用”,然后在指标过滤条件中选择“响应延迟时间”。如果要检查特定服务,您还可以使用过滤条件按特定模块进行过滤以查看响应延迟时间图表。
现在您已经设置了自定义图表,我们来看看下一部分,了解如何为若干秒数的延迟时间设置通知。
提醒
如需创建提醒政策,请执行以下操作:
- 设置通知,在 Cloud Monitoring > 提醒中创建提醒政策,然后点击 + 创建政策。
点击添加条件以向提醒添加条件。
前往“提醒”页面
选择“GAE 应用”作为目标:
例如,如果您希望收到响应延迟时间提醒(例如 App Engine 应用响应的时长),请选择响应延迟时间。
如有必要,您还可以选择模块 ID,并添加阈值和通知渠道。如需了解相关说明,请参阅管理通知渠道。
创建完政策后,您将在“提醒”页面的列表中看到该政策。点击已创建的政策以查看详细信息,如下图所示:
恭喜,您刚刚创建了第一个 App Engine 延迟时间政策!在您创建政策后,如果应用检测到突发事件,则会向所选渠道发送提醒。
调试延迟时间
查看 App Engine 延迟时间信息中心
通常,如果您要查看 App Engine 应用的延迟时间,请转到 App Engine > 信息中心,然后选择延迟时间图表。
转到 App Engine 信息中心
在延迟时间图表中,您可以按服务、版本和时间间隔过滤图表来深入了解数据。
在上图中,请注意应用延迟时间如何从几毫秒变为将近 25 秒。
了解应用延迟时间
如需了解现在特定请求需要多长时间,请转到:
Cloud Logging
在 Cloud Logging 中,您可以找到两类日志:请求日志和应用日志。对于发送到应用的每个请求,App Engine 会自动写入请求日志,其中包含 HTTP 方法、响应代码等。应用日志是您为应用编写的日志。
如需查看请求日志或应用日志,请参阅查看日志。
Cloud Trace
Cloud Trace 对于了解请求如何在您的应用中传播非常有用。您可以检查单个请求的详细延迟时间信息,也可以查看整个应用的总体延迟时间。
如需在 Cloud Trace 中查看跟踪记录详细信息,您可以按照查找和探索跟踪记录进行操作。在 Trace 探索器中,如下图所示,您可以使用过滤条件按特定 App Engine 服务和版本进行过滤。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThis page guides you through monitoring and receiving alerts for elevated latency in Google App Engine applications.\u003c/p\u003e\n"],["\u003cp\u003eHigh latency in App Engine can be monitored using Cloud Monitoring's Metrics Explorer, which allows for customized graphs and filters based on service or module.\u003c/p\u003e\n"],["\u003cp\u003eAlerting policies for response latency can be created in Cloud Monitoring, where you can set thresholds and notification channels to receive alerts when latency exceeds specified levels.\u003c/p\u003e\n"],["\u003cp\u003eTo debug latency issues, you can check the App Engine dashboard's latency graph, which allows filtering by service, version, and interval.\u003c/p\u003e\n"],["\u003cp\u003eCloud Logging and Cloud Trace are available tools to further understand and debug app latency, allowing you to view request and application logs, and track request propagation through the application.\u003c/p\u003e\n"]]],[],null,["# Monitoring and alerting latency\n\nThis page describes how to monitor and get alerts from elevated latency in\nGoogle App Engine.\n\nHigh latency for App Engine apps can occur for various reasons. For\nexample, the app does not have optimized code, there aren't enough resources,\nthere are busy machines, and so forth. This guide focuses on the latency\ngenerated by App Engine regardless of the reason.\n\nIt is important to understand that high latency can often lead to 5xx errors.\nTherefore, rapid detection of high latency can help you act in time and thus\nresolve application errors.\n\nSetting up Monitoring and Alerting\n----------------------------------\n\n### Monitoring\n\nIf you want to create a customized graph to monitor your app's response latency,\nuse **Cloud Monitoring** \\\u003e **Metrics Explorer** to build your own graph.\n\n[Go to Metrics Explorer page](https://console.cloud.google.com/monitoring/metrics-explorer)\n\nIn the **Resource Type** , select *GAE Application* and select *Response latency*\nin the **Metric** filter. If you have a specific service to check, you can also\nuse **Filters** to filter by the specific module to see the response latency\nchart.\n\nNow that you've set up your customized graph, let's take a look at the next\nsection and learn how to set up notifications for latencies over a certain\namount of seconds.\n\n### Alerting\n\nTo create an alerting policy, do the following:\n\n1. Set up notifications, create an alerting policy in **Cloud Monitoring** \\\u003e **Alerting** and click on **+ CREATE POLICY**.\n2. Add a condition to your alert by clicking **ADD CONDITION**.\n\n [Go to Alerting page](https://console.cloud.google.com/monitoring/alerting)\n3. Select GAE Application as a target:\n\nFor example, if you wanted to get alerts for response latency, such as how long\nyour App Engine app is taking to respond, select response latency.\n\nYou can also select the module ID if it's appropriate, and add a threshold and a\nnotification channel. See\n[Managing notification channels](https://cloud.google.com/monitoring/support/notification-options)\nfor instructions.\n\nAfter you have finished creating the policy, you will see the policy in a list\nin the Alerting page. Click on the created policy to see the details, as shown\nin the following image:\n\nCongratulations, you just created your first App Engine latency policy!\nAfter you create your policy, the app will send an alert to the selected channel\nif it detects an incident.\n\nDebugging latency\n-----------------\n\n### Checking the App Engine latency dashboard\n\nIn general, when you want to see the latency of App Engine applications,\ngo to **App Engine** \\\u003e **Dashboard** and select the **Latency** graph.\n\n[Go to App Engine dashboard](https://console.cloud.google.com/appengine)\n\nIn the latency graph, you can drill into the data by filtering the graphs by\nservice, version, and interval.\n\nIn the previous image, notice how the application latency varies from a few\nmilliseconds to almost 25s.\n\n### Understanding app latency\n\nTo understand now how long a particular request has taken, go to:\n\n- [Cloud Logging](/logging) to view request logs and application logs.\n- [Cloud Trace](/trace) to track how requests propagate.\n\n#### Cloud Logging\n\nIn Cloud Logging you can find two categories of logs, request logs and\napplication logs. Request logs are automatically written by App Engine\nfor each request to your application and contains the HTTP method, response\ncode, and so forth. Application logs are those that you write for your\napplication.\n\nTo view request logs or application logs, see\n[Viewing logs](/appengine/docs/legacy/standard/go111/writing-application-logs#viewing_logs).\n\n#### Cloud Trace\n\nCloud Trace is useful for understanding how requests propagate through your\napplication. You can inspect detailed latency information for a single request\nor view aggregate latency for your entire application.\n\nTo view trace details in Cloud Trace, you can follow\n[Find and explore traces](/trace/docs/finding-traces).\nIn the [Trace explorer](https://console.cloud.google.com/traces/list), as shown in the following\nimage, you can use the filters to filter by your specific App Engine\nservice and version."]]