Search code examples
google-cloud-platformgoogle-cloud-logginggoogle-cloud-ops-agent

GCP Logs resource_name is not the VM hostname but image source disk name


How to configure GCP log's resource_name to be the VM hostname?

I collect logs from GCP VMs using ops-agent. However, the labels.compute.googleapis.com/resource_name is not showing the hostname of the VM. Instead, it is showing the source disk of the VM's boot image.


Solution

  • After my own troubleshooting, it happens to be some residue problem of my custom image. Upon reboot of the VM creation, the hostname is correctly and effectively changed.