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

306 Views Asked by At

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.

2

There are 2 best solutions below

0
kristen_1024 On BEST ANSWER

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.

0
Leo Y On

Please, consult the official documentation about the default behavior of Ops Agent. You can alter the configuration given the info you are searching is a part of the log entry metadata or payload. Otherwise, you can use the instance id of the VM (stored at resource.labels.instance_id) instead of the hostname.