简体   繁体   中英

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.

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)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM