How to get uptime total and percentage of GCP compute vm instance through MQL?

Solution 1:

you can try with the uptime metric instead :

fetch gce_instance
| metric 'compute.googleapis.com/instance/uptime'
| filter (metric.instance_name == 'instance-1')
| align delta(1d)
| every 1d
| group_by [], [value_uptime_mean: mean(value.uptime)]

so you get a graph similar to this one:

enter image description here