What the script creates
Every name comes from--name (default observer-agent):
- A Secret Manager secret
observer-agent-keythat holds the agent key. The key is never in the VM’s metadata. - A service account
observer-agent@<project>.iam.gserviceaccount.comthat may read only that secret. - Two firewall rules on the network, for the VM’s network tag:
observer-agent-allow-iap-sshallows SSH from Identity-Aware Proxy (35.235.240.0/20) andobserver-agent-deny-ingressdenies every other inbound connection. - A VM
observer-agent:e2-micro, Debian 12, a 10 GB balanced disk, Shielded VM and OS Login turned on. Its startup script reads the key with the service account and runs the install script, which installs the agent binary as theobserver-agentsystemd service. Later boots skip the install.
Before you start
- Create the agent in Observer: Agents, Add agent, then Cloud platforms. Copy the key. Observer shows it once.
- To check private services, note their VPC network and subnet. The
subnet needs outbound internet access: keep the VM’s external IP (the
default), or use a subnet with Cloud NAT and pass
--no-address.
Deploy from Cloud Shell
1
Open Cloud Shell
Choose Open in Cloud Shell above and confirm. Cloud Shell clones
the agent repository and opens a short tutorial next to the terminal.
2
Choose the project
3
Run the script
--network <name> and --subnet <name>. When
it finishes, it prints the command that shows the agent’s logs and the
one that removes everything it created.Deploy from any shell
Wheregcloud is installed and signed in:
AGENT_KEY the script asks for the key on the terminal.
Flags
Running the script again is safe: it adds the key as a new secret
version and leaves an existing VM as it is.
Check that it connected
A minute or two after the script finishes, the Add agent screen shows Connected and the Agents page marks the agent as running. If it does not connect, read the agent’s logs through Identity-Aware Proxy (the script prints this command with your values):observer-agent service does not exist, the install failed.
Read the startup script’s output with
sudo journalctl -u google-startup-scripts.service on the VM. The
usual cause is a subnet without outbound internet access.
Add settings and secrets
The agent reads its environment from/etc/observer-agent/agent.env.
To add a variable, such as PROMETHEUS_SERVER_URL or a secret that a
probe references by name (connection_string_ref and the like), edit
the file over IAP SSH and restart the service:
AGENT_KEY in the same file. The VM reads Secret Manager only
for its first install. See
Environment variables for
every setting.
Upgrades
The VM installs the agent binary with the install script. To upgrade, run the script again on the VM. It replaces the binary, restarts the service, and keeps the key and your settings:sh -s -- --version <X.Y.Z> in place
of sh.
Remove
From the same repository checkout (Cloud Shell keeps it in your home directory), run the script with--delete and the same project, zone
and name:

