API to calculate the total time a VM is available or down since its creation

443 Views Asked by At

I am trying to prepare a VM Availability Report for compute Engine Instances. For this I need to gather the following metrics:

  1. The Time VM was available since its creation
  2. The Time VM was down

When I went through the metrics api, in https://cloud.google.com/monitoring/api/metrics_gcp#gcp-monitoring I got the following apis:

  1. compute.googleapis.com/instance/uptime Description: Delta of how long the VM has been running, in seconds
  2. compute.googleapis.com/instance/uptime_total Description: Elapsed time since the VM was started

If I need to get the total time the VM was available since its creation, should I use the uptime or uptime_total? How to find that in % instead of seconds? What is the difference between the two APIs?

If I need to calculate the downtime of the VM I am finding no REST APIs for that, is there any API which can give the times the VM has been down in a month or so?

0

There are 0 best solutions below