> ## Documentation Index
> Fetch the complete documentation index at: https://docs.use.observer/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on any cloud with cloud-init

> Paste cloud-init user data when you create a Linux VM, and the agent installs itself on the first boot.

Most clouds run cloud-init on their Linux images, including Vultr,
Linode, Scaleway, UpCloud, Exoscale and DigitalOcean Droplets. Paste the
user data below when you create a VM in the network of the services to
check, and the VM installs the Observer Agent on its first boot. From
there the agent checks what that network can reach, such as private
databases, internal APIs and Prometheus. It only makes outbound calls,
so the VM needs no inbound rule. Your cloud's pricing applies.

```yaml theme={null}
#cloud-config
runcmd:
  - |
    curl -fsSL --retry 5 https://use.observer/install.sh -o /tmp/observer-install.sh &&
      AGENT_KEY="obs_live_..." sh /tmp/observer-install.sh
    rm -f /tmp/observer-install.sh
```

The user data runs the [install script](https://docs.use.observer/agent/reference/install-script.md)
once, as root. It installs the agent binary as the `observer-agent`
systemd service. The console gives you a copy with your key filled in.

> [!NOTE]
>
> **Where the key is stored**
>
> The key is in the VM's user data. Programs on the VM can read it from
> the cloud's metadata service, and so can the users of your cloud
> account who can read the VM's settings.

## Before you start

* Create the agent in Observer: **Agents**, **Add agent**, then
  **Cloud platforms**. Under **Any other cloud**, choose **Copy user
  data**. Observer shows the key once.
* Pick a Linux image with cloud-init, such as Ubuntu or Debian. Most
  clouds' standard images have it.
* To check private services, put the VM in their private network, with
  outbound internet access: a public IP, or a NAT gateway.

## Deploy

**1. Create the VM**

Start creating a VM in your cloud's console. A small size is enough:
one vCPU and 1 GB of memory.

**2. Paste the user data**

Find the user data field. Clouds call it **User data**, **Cloud-init**
or an initialization script, usually under the advanced options. Paste
the user data from the console.

**3. Create it**

Create the VM. It boots, downloads the agent and starts it.

## Check that it connected

A few minutes after the VM starts, the Add agent screen shows
**Connected** and the Agents page marks the agent as **running**.

If it does not connect, open a shell on the VM and read the cloud-init
output, where the install script prints each step:

```bash theme={null}
sudo cat /var/log/cloud-init-output.log
```

The usual cause of a failed install is a VM without outbound internet
access. Once the agent is installed, read its own logs:

```bash theme={null}
sudo journalctl -u observer-agent -f
```

The agent logs every failed call to Observer with the reason. The most
common cause is a wrong or replaced agent key.

## 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 and restart the service:

```bash theme={null}
sudo vi /etc/observer-agent/agent.env
sudo systemctl restart observer-agent
```

After a [key rotation](https://docs.use.observer/agent/guides/rotate-agent-key.md), put the new
key in `AGENT_KEY` in the same file. See
[Environment variables](https://docs.use.observer/agent/reference/environment-variables.md) for
every setting.

## Upgrades

To upgrade, run the install script again from a shell on the VM. It
replaces the binary, restarts the service, and keeps the key and your
settings:

```bash theme={null}
curl -fsSL https://use.observer/install.sh | sh
```

To install a given release, add `-s -- --version <X.Y.Z>` after `sh`.

## Remove

Delete the VM in your cloud's console. Delete the agent in Observer
(**Agents**) too if you no longer need it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.