GCP Cloud Run:如何监控每个路径/URI的延迟?

huangapple go评论52阅读模式
英文:

GCP Cloud Run: how to monitor latency per path/URI?

问题

Sure, here's the translated content:

我在GCP Cloud Run上运行着REST API。我想要监控延迟/响应时间,按路径(URI)分组,以便我可以发现响应时间较差的路径。

例如,假设我有3个路径,我想要看到一些指标如下:

  • /v1/users → 50%分位数:500毫秒,95%分位数:2400毫秒
  • /v1/book → 50%分位数:240毫秒,95%分位数:1003毫秒
  • /v1/readlists → 50%分位数:10毫秒,95%分位数:13毫秒

我尝试使用监控和跟踪创建某种可视化,但未能筛选(以便仅查看/v1 URI)和分组(按路径)。到目前为止,我最好的结果是在跟踪上生成了一个报告,显示了/v1的这些指标。从理论上讲,我可以为每个端点创建一个报告,但这看起来很繁琐,我确信我可以在一个可视化中进行分组。

我是一个GCP监控的初学者,这是否可行?

**编辑以澄清:**我希望使用监控(以便可以在我的仪表板上看到它)或其他产品来实现这一点。但我想避免修改应用程序代码(例如使用Cloud Endpoint)。我知道我想要的指标已经可用,因为我可以为每个端点生成一个跟踪报告。我只是缺少一种在单个位置显示这些数据的方法,而无需手动指定每个端点。

英文:

I have REST API running on GCP Cloud Run. I would like to monitor latency / response time, grouped per path (URI), so that I can spot paths that have bad response times.

For instance, let say I have 3 paths, I would like to see some metrics like:

  • /v1/users → percentile 50%: 500 ms, percentile 95%: 2400 ms
  • /v1/book → percentile 50%: 240 ms, percentile 95%: 1003 ms
  • /v1/readlists → percentile 50%: 10 ms, percentile 95%: 13 ms

I tried creating some kind of visualization with Monitoring and Trace, but failed to filter (so that I see only /v1 URIs) and group (by path). The best I have so far is a report on Trace that show me these metrics for /v1. I could theoretically create one report per endpoint, but that looks cumbersome and I am certain I can do the grouping on 1 visualization.

I am a beginner on monitoring on GCP, is it possible to do this?

Edit for clarification: I would like to do it using Monitoring (so that I can see it on my dashboard) or another product. But I would like to avoid modifying the application code (such as with Cloud Endpoint).
I know the metrics I want are already available, because I can generate a Trace report for each endpoint. I am just missing a way to display that data in a single place, without having to manually specify each endpoint.

答案1

得分: 1

一种选择是为您的 API 配置 Cloud Endpoints。它会自动报告请求计数、有效负载大小和延迟给 Cloud Monitoring 按方法(文档中的方法指的是 HTTP method + HTTP path 组合)。

可以直接使用 Cloud Trace 和 Cloud Monitoring,也能正常运行。

但无法过滤(这样我只看到 /v1 URIs)并分组(按路径)。

只需按完整路径进行过滤。对于 Cloud Trace,这将类似于 +url:/v1/users。只要路径中没有 ID,普通的过滤就可以正常运行。

英文:

One option is to configure Cloud Endpoints for your API. It will automatically report request counts, payload sizes, and latencies to Cloud Monitoring per method (method in the docs means HTTP method + HTTP path combination). That should fit your needs.

Directly using Cloud Trace and Cloud Monitoring should also work fine.

> but failed to filter (so that I see only /v1 URIs) and group (by path)

You only need to filter by the full path. For Cloud Trace, this would look something like +url:/v1/users. A plain old filter should work fine as long as you don't have IDs in the paths.

Ref: https://cloud.google.com/trace/docs/trace-filters#filter_syntax

huangapple
  • 本文由 发表于 2023年4月17日 04:35:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030195.html
  • google-cloud-monitoring
  • google-cloud-platform
  • google-cloud-run
  • google-cloud-trace
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定