Search code examples
node.jsgoogle-cloud-platformnestjsgoogle-cloud-rungoogle-cloud-metrics

GCP Cloud Run Revision Request Count Metric Group By Route But Route is Empty


I am trying to set up alerting per route for my GCP Cloud Run service. Of the default metrics collected by default Request Count of the Cloud Run Revisions looks like a good candidate. My issue is that the 'route' label on these metrics is always empty. Is there something additional I need to configure to get this to populate?

It seems out that a label would exist on an out of the box metric that is never populated.

I am running a nodejs app us the nestjs framework.

I tried to group the Cloud Run Revision Request Count metric by Route but found that Route is always empty. I was expected the Route label to be populated with the api endpoint / url path for each request.


Solution

  • That is accurate, yes. Because it is not yet supported, the route label for the Cloud Run Revisions Request Count statistic is always empty. The Cloud Run team is attempting to resolve this issue, which is known.

    In the meantime, you can use one of the workarounds that mentioned by @guillaume blaquiere in to set up alerting per route for your Cloud Run service.

    Here are some workarounds that might help:

    • Use a custom metric. You can create a custom metric that tracks the number of requests per route. To do this, you will need to write a custom metric exporter that collects the data from your application and exports it to Cloud Monitoring.

    • Use a third-party monitoring solution. There are a number of third-party monitoring solutions that support Cloud Run. These solutions typically collect more detailed metrics than Cloud Monitoring, including the route label.

    If you are using a custom metric exporter, you can collect the path from the request object. For example, in Node.js, you can use the req.url property.

    If you are using a third-party monitoring solution, you should consult the documentation for that solution to learn how to collect the path.

    Once you have collected the path, you can export it to Cloud Monitoring as a custom metric or send it to the third-party monitoring solution.

    You may also file a feature request in this link. However, there is no ETA for it. once you create a feature request you can also check the progress of your request.