Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitor Google Cloud Run memory usage

Is there any built-in way to monitor memory usage of an application running in managed Google Cloud Run instances?

In the "Metrics" page of a managed Cloud Run service, there is an item called "Container Memory Allocation". However, as far as I understand it, this graph refers to the instance's maximum allocated memory (chosen in the settings), and not to the memory actually used inside the container. (Please correct me if I'm wrong.)

In the Stackdriver Monitoring list of available metrics for managed Cloud Run ( https://cloud.google.com/monitoring/api/metrics_gcp#gcp-run ), there also doesn't seem to be any metric related to the memory usage, only to allocated memory.

Thank you in advance.

like image 744
favq Avatar asked Sep 15 '19 17:09

favq


3 Answers

Cloud Run now exposes a new metrics named "Memory Utilization" in Cloud Monitoring, see more details here.

This metrics captures the container memory utilization distribution across all container instances of the revision. It is recommended to look at the percentiles of this metric: 50th percentile, 95th percentiles ad 99th percentiles to understand how utilized are your instances

like image 54
Steren Avatar answered Jan 03 '23 20:01

Steren


Currently, there seems to be no way to monitor the memory usage of a Google Cloud Run instance through Stackdriver or on "Cloud Run" page in Google Cloud Console.

I have filed a feature request on your behalf, in order to add memory usage metrics to Cloud Run. You can see and track this feature request in the following link.

like image 20
Deniss T. Avatar answered Jan 03 '23 21:01

Deniss T.


There is not currently a metric on memory utilization. However, if your service reaches a memory limit, the following log will appear in Stackdriver Logging with ERROR-level severity:

"Memory limit of 256M exceeded with 325M used. Consider increasing the memory limit, see https://cloud.google.com/run/docs/configuring/memory-limits"  

(Replace specific numbers accordingly.)

Based on this log message, you could create a Log-based Metric for memory exceeded.

like image 26
Grayside Avatar answered Jan 03 '23 20:01

Grayside