-1

I have a number of instances in a GCP project, that I want to check retroactively how long they've been in use in the last 30 days, i.e. sum the total time an instance is not stopped or terminated during a specific month.

Does anyone know if this can be calculated, and if so - how? Or maybe another idea that would allow me to sum the total time an instance was in use?

Aby_sdc
  • 3
  • 2

1 Answers1

0

Based on this other post, I would recommend something like:

fetch gce_instance
| metric 'compute.googleapis.com/instance/uptime'
| align delta(30d)
| every 30d
| group_by [metric.instance_name]

I would also consider creating uptime_checks as one of the answers in said post recommends for future checks, but those wouldn't work retroactively. If you need more info about MQL you can find it here.

Lluís Muñoz
  • 409
  • 3
  • 11