Does the start up script need to modified at all before pasting in when creating the VM? I do not have anything show up in my bucket after redoing this lab a couple times in different accounts.
Nope, the script does not need to be edited at all.
It’s helpful to check logs on your VM, what exactly was happened. The possible reason could be access permissions.
Still for me also same, nothing got reflecting in bucket after creating VM with given script
The instance you create is very small so it takes time to process the whole script and get to the part where it copies the log to the bucket. I had to wait about 10 minutes before it appeared. If you want to make sure things are going smothly, you can log into the instance and check for the running commands.
The output of the startup script can be monitored with the folowing command:
sudo journalctl -u google-startup-scripts.service
It can be really useful to view the serial port output for the instance to see what exactly is going on. For example, if the scopes aren’t set up correctly or the service account doesn’t have sufficient access, then the StackDriver agent will install and run successfully but then the gsutil command will throw a 403 error.
To enable serial port access, you’ll have to set the metadata at either the project or instance level – the docs detail both commands.
You can view the serial port output from the console by selecting the instance and then clicking the Connect to Serial Console button or the "Serial port 1" link under logs; you can also view the output by running "gcloud compute instances get-serial-port-output my-instance". The response will return a pagination token, so that you can just pull fresh items. I’d recommend connecting to the console via the button for this – it opens in a separate window and streams the console output as it’s generated, which allows you to watch the script execute.
Note that the startup script doesn’t provide the gs:// prefix on the gsutil cp command. gs:// should be part of the metadata for the bucket.
In the script provided by the instructor replace:
bash add-logging-agent-repo.sh –also-install
See the docs here for more info about the change https://cloud.google.com/logging/docs/agent/installation as google may update their services.