0

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 Answers2

0

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.

Leo Y
  • 659
  • 7
  • 22
0

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.