I have been trying to get the details about how long the VM has been running. Upon researching, I found that the instance/uptime metric could provide this information. However, I'm interested in obtaining monthly data for the past few years.
Despite having a running instance, the metric explorer pages started throwing "no date is available for the selected timeframe".
Is there a retention period for metrics similar to what we have for Cloud Logging?
When you access the instance through SSH, execute the command ‘uptime -p’ to obtain information about how long the VM has been running, but the standard retention period for all Cloud Monitoring metrics is 6 weeks only.
As per this official GCP documentation (How to query extended retention metrics):
Google Cloud is slowly rolling out 24 months retention, but it is not generally available yet. You can refer to the above official GCP doc for more details.