Aditya Sahu
Aditya Sahu

Reputation: 1

How to generate monthly uptime report of GCP compute engine vm

I am trying to generate MONTHLY report for total uptime of a single GCP compute vm instance inclusive of restarts.

Eg: In the past 24 hours if instance is not running for 1hr , i expect the mql query to return 23 hrs

MQL query used:

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

This query is not providing the exact timings my servers are up/down. If you have any idea on how to get information of total uptime through MQL that would be very helpful. Thank you.

Upvotes: 0

Views: 1114

Answers (1)

Cheng Hou
Cheng Hou

Reputation: 91

According to the metric description in Google Cloud metrics, I think you should use compute.googleapis.com/instance/uptime_total for the calculation.

fetch gce_instance
| metric compute.googleapis.com/instance/uptime_total
| filter (metric.instance_name == 'instance-1')
| group_by [], sliding(30d), [uptime_total_sum: sum(value.uptime_total)]

Upvotes: 0

Related Questions