I'm trying to get disk information required for metric filter:
"filter": f'metric.type="agent.googleapis.com/disk/percent_used" AND metric.labels.state="used" AND metric.labels.device="{self.disk}" AND resource.labels.instance_id="{self.instance}"
where self.disk should be like /dev/disk but I'm not able to get this information using googleapiclient.discovery or google.cloud.compute_v1 (InstancesClient, DiskClient)
Is there any possibility to get this information?
To retrieve the disk information needed for the metric filter, it cannot directly obtain the device paths (like
dev/disk) using the Google Cloud Python libraries (googleapiclient.discoveryorgoogle.cloud.compute\_v1). However, you can still fetch the relevant details through the Compute Engine API.You can utilize the
DiskListFilterclass from thegoogle.api\_core.page\_iteratormodule to filter disks based on their labels. In particular, you want to find disks associated with your desired instance and then extract the corresponding names.You may try this example as reference: