You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何按端点跟踪App Engine的请求、浏览量及响应时间指标?

App Engine 按端点细分指标跟踪方案

核心思路:利用指标自带标签+自定义标签实现分组

App Engine 的 http/server/response_count 和 http/server/response_latencies 指标默认携带 endpoint(或 request_path,依运行环境而定)标签,可直接用于按端点分组统计;若需更自定义的维度(如页面标识),则需补充自定义标签。

1. 按端点统计每秒请求量

  • 在 Cloud Monitoring 中创建图表,选择 http/server/response_count 指标
  • 在「分组依据」中勾选 endpoint 标签
  • 聚合方式设置为「速率(Rate)」,时间粒度设为1秒,即可得到各端点的每秒请求数

2. 按页面统计每秒浏览量

  • 若页面与端点路径一一对应,直接用上述方法,筛选目标 endpoint 值即可
  • 若需自定义页面标识,需在应用代码中给请求添加 page 自定义标签:
    • 以 Python 标准环境为例,可通过 google-cloud-monitoring 库上报带标签的自定义指标(示例代码如下):
      from google.cloud import monitoring_v3
      from datetime import datetime
      
      def record_page_view(project_id, page_path):
          client = monitoring_v3.MetricServiceClient()
          project_name = f"projects/{project_id}"
          series = monitoring_v3.TimeSeries()
          
          # 定义自定义指标类型
          series.metric.type = "custom.googleapis.com/page_views"
          series.resource.type = "gae_app"
          # 添加页面标签
          series.metric.labels["page"] = page_path
          
          # 设置数据点(当前时间+计数1)
          point = series.points.add()
          point.value.int64_value = 1
          now = datetime.now(tz=datetime.timezone.utc)
          point.interval.end_time = {"seconds": int(now.timestamp()), "nanos": now.microsecond * 1000}
          
          client.create_time_series(name=project_name, time_series=[series])
      
    • 之后在 Cloud Monitoring 中基于自定义指标 custom.googleapis.com/page_views,按 page 标签分组统计速率即可

3. 按端点统计响应时间

  • 选择 http/server/response_latencies 指标,分组依据勾选 endpoint 标签
  • 聚合方式按需选择:平均响应时间选「均值(Mean)」,长尾延迟选「p95」「p99」等百分位数,时间粒度根据监控需求设置

4. 确认标签可用性

若在指标浏览器中看不到 endpoint 标签,可检查:

  • 应用是否为 App Engine 标准环境(灵活环境部分指标标签可能不同)
  • 是否开启了完整的 HTTP 指标采集(默认已开启,若有自定义配置需确认)

内容的提问来源于stack exchange,提问作者Joel Burget

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 14:32:38